Greenhorn Greenhorn - 1 year ago 54
jQuery Question

Unable to fetch values from an input element in Bootstrap's popover

I'm trying to fetch values from some input fields that are placed in a Bootstrap Popover. But I get empty string.

Complexity: There is a button within a form, when you click this button a popover appears with 2 input fields and a button. I want to capture the values of these 2 fields when we click the button. If I put these fields in a form, then it would become nested forms.

Following is my code.

<button type="button" class="btn btn-danger popper hyperlink" data-toggle="popover">Trial</button>
<div class="popper-content hide">
<input type="text" class="form-control" id='urlLabel' placeholder="URL Label">
<input type="text" class="form-control url" id='url' placeholder="Complete URL">
<button type="button" class="btn btn-default btn-block urlDetails">Done</button>

My way of fetching values


Here is my JSFiddle covering the above case.

Answer Source
Try following code:

$(document).ready(function() {
    $(document).on('click', '.urlDetails', function() {