<分区>
<分区>
我正在使用 javascript 动态生成 html 表。 为每一行添加按钮并为此添加一个 css 类,不会调用该 css 类的 onlick 事件。在我犯错的地方需要帮助。
Here is my code for reference
for(var i=0;i<5;i++){
$("#desgtable").append("<tr rowindex='Number(i+1)'><td>"+i+"</td><td><input type='button' class='case' </td></tr>");
}
$(".case").click(function(){
alert();
}
最佳答案
使用事件委托(delegate):
$(document).on('click',".case",function(){
alert();
});
关于jquery - css 事件类 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31042223/