我做了以下弹出窗口: https://jsfiddle.net/ca4h0a0q/
<a class='danger' data-placement='above' title="Popover Title" href='#'>Click</a>
<div id="popover_content_wrapper" style="display: none">
<button class="close">
x
</button>
<div>This is your div content</div>
</div>
Javascript:
$(document).ready(function(){
$("body").on("click",".close",function(){
$(".danger").trigger("click");
});
$('.danger').popover({
html : true,
content: function() {
return $('#popover_content_wrapper').html();
}
});
});
为了关闭弹出窗口,由于此错误:https://github.com/twbs/bootstrap/issues/16732我必须在打开它的按钮上触发单击事件。我不太喜欢这个解决方案。有更好的方法吗?
最佳答案
我就是这样工作的。
<div id="popover_content_wrapper" style="display: none">
<button class="close" onclick="$('.danger').popover('hide').trigger('click')">
x
</button>
<div>This is your div content</div>
还有 js...
$(document).ready(function(){
$('.danger').popover({
html : true,
content: function() {
return $('#popover_content_wrapper').html();
}
});
});
关于javascript - Bootstrap 弹出窗口,关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45399746/