我在bootstrap popover中放置了带有一些输入的自定义html。现在我想用JavaScript绑定这些输入,但我做不到……
所以,这里有一个简单的例子,可以更清楚地解释我的问题:http://jsfiddle.net/53pD6/16/
<button class="btn btn-small btn-popover" type="button" data-original-title="Popover" data-placement="bottom">*</button>
<!-- Popover html boby (Display attribute is none!) -->
<div id="popover_content_wrapper" style="display: none">
<input type="checkbox" class="chbox"/>Click me (no effect)
</div>
<input type="checkbox" class="chbox"/>Click me (here it's Ok)和JS:
$(function(){
$('.btn-popover').popover({
html : true,
content: function() {
return $('#popover_content_wrapper').html();
}
});
$(".chbox").change(function(){
alert(1);
});
});我只想在弹出框中绑定复选框到函数。我该怎么做呢?
发布于 2013-07-16 22:19:34
由于.popover()不提供附加事件处理程序的方法,因此我所知道的解决此问题的唯一方法是:
$('body').on('click', '.chbox', function () {
alert(1);
});http://jsfiddle.net/53pD6/17/
https://stackoverflow.com/questions/17677032
复制相似问题