我试图在单击idtagit的按钮时提醒消息。但整个表单都出现在bootstrap弹出窗口中。我还添加了用于警报消息的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");
});

08-16 06:32