I'm trying to get the input value inside a Bootstrap popover on submit, but i got a empty value.
<div class="popover-markup"> <a href="#" class="trigger">Popover link</a>
<div class="head hide">Lorem Ipsum</div>
<div class="content hide">
<div class="form-group">
<input type="text" id="myinput" class="form-control" placeholder="Type something…">
</div>
<button type="submit" id="mysubmit" class="btn btn-default btn-block">Submit</button>
</div>
<div class="footer hide">test</div>
</div>
$('.popover-markup>.trigger').popover({
html: true,
title: 'Get value',
content: function () {
return $(this).parent().find('.content').html();
}
});
$(document).on("click", "#mysubmit", function () {
var inputval = $("#myinput").val();
alert(inputval);
return false;
});
http://jsfiddle.net/onigetoc/RvLrA/
Try referencing it like this:
var inputval = $(".popover #myinput").val();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With