语法:
元素.on('事件名称','给里面哪个元素','功能函数');
案例:
$("#list").on('click','tr td button',function(){
alert(1);
});
向list中添加元素
$("#list").append(dom);
在动态生成的页面元素只能通过on()进行事件绑定,删除元素
$("#list").on('click','tr td button',function(){
$(this).parents().remove();
});
当前点击的button执行删除它的父元素且名字是tr
$("#list").on('click','tr td button',function(){
$(this).parents("tr").remove();
});
如何让list里面所有class为check的复选框设置相同的状态
$("#checkAll").click(function){
var flag=$(this).prop("checked");
$("#list .check").prop("checked",flag);
});