对表格的td标签执行点击事件

来源:互联网 发布:中老年春秋连衣裙淘宝 编辑:程序博客网 时间:2024/06/06 06:49

对于表格中的td如何执行事件
html:

<table  id="example" ><thead><tr> <th>编号</th> <th>名称</th> <th>操作</th></tr></thead><tbody><tr> <td>1</td> <td>电脑</td> <td> <button id='delete' type='button'>删除</button> </td> </tr><tr> <td>2</td> <td>手机</td> <td><button id='delete' type='button'>删除</button></td> </tr></tbody></table>

最简单的table表格
table类下找到对谁执行这个事件

$('#example tbody').on('click', 'button#delrow', function () {     var tt = $("#example").DataTable();      tt.row($(this).parent('tr')).remove();  //删除你点击的行   });
原创粉丝点击