我在链接上有一个弹出窗口,通过 JavaScript 初始化。在弹出窗口本身中,有一个调用函数的链接。但是,当单击弹出窗口内的链接时,没有任何反应。任何想法?我找不到这方面的答案。
链接和弹出窗口内容:
<a tabindex="0" href="#" role="button" class="remove-item-toggle">Remove</a>
<div id="remove-item-content" style="display: none;">
<a href="#" class="remove-item">Confirm remove</a>
</div>
JavaScript:
$('.remove-item-toggle').popover({
toggle: 'popover',
trigger: 'click',
html: true,
placement: 'top',
content: $('#remove-item-content').html(),
});
$('.remove-item').on('click', function () {
// ---- nothing happens here, it's not fired ----
});
最佳答案
一旦显示
弹出窗口,就应该分配click
处理程序...
$('.remove-item-toggle').on('shown.bs.popover', function () {
$('.remove-item').on('click', function () {
console.log("works");
});
})
关于jquery - Bootstrap 4 Popover Javascript 显示后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50075734/