2015-05-14 44 views
1

我想提醒一条消息,当点击编号为tagit的按钮时。但是整个表格都出现在bootstrap popover中。我还添加了jquery警报消息,但它没有显示任何警告对话框,但是当我在JavaScript中调用相同的东西时,它显示警报。但我需要它在jQuery中。我怎样才能做到这一点?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");   
}); 
+0

使用代表团 –

回答

5

您需要使用event delegation,像这样

$(document).on('click', "#tagit", function() { 
    console.log("hello this is working");   
}); 
1

事件委托动态创建的DOM元素。尝试使用立即父母选择器来轻松快速地遍历

$(document).on('click', '#tagit', function() { 

}):