The click event written directly in the page is valid:
<a class="deleteCls" beanId="${bean.id }" href="javascript:void(0)">删除</a> $("a.deleteCls").click(function() { alert("del"); });
But the code generated in js:
str += "<td><a class='deleteCls' beanId='" + item.id + "' href='javascript:void(0)'>删除</a></td>";
The click is invalid. I checked the information and said that it was the code generated later. jQuery did not bind the click event. Specifically, I did not do any in-depth understanding.
Here is the workaround:
Will
$("a.deleteCls").click(function() { alert("del"); });
Modify it to (tableList is the id of the table table, and the generated code is in the table tag):
$("#tableList").on("click","a.deleteCls",function(){ alert("del"); });
Solved, now the click event of the generated code can also respond!