[英]How to pass an argument to a button click function inside bootstrap popover content?
[英]Jquery click function not working for the button inside popover
當我單擊ID為tagit
按鈕時,我想提醒一條消息。 但是整個表單顯示在引導彈出窗口中。 我還添加了用於警告消息的jquery,但是它沒有顯示任何警告對話框,但是當我在javascript中調用同一件事時,它正在顯示警告。 但我需要它在jQuery中。 我怎樣才能做到這一點?
var htmlcont ='<table class="pop-table"><tr><td><button class="btn btn-warning" id="tagit">FILTER</button></td></tr></table>';
$('[data-toggle="popover"]').popover({content: htmlcont, html: true});
$("#tagit").click(function(){
alert("hello this is working");
});
您需要像這樣使用event delegation
$(document).on('click', "#tagit", function() {
console.log("hello this is working");
});
動態創建的DOM元素的事件委托 。 嘗試使用立即父選擇器輕松快速地遍歷
$(document).on('click', '#tagit', function() {
}):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.