【发布时间】:2014-08-24 02:49:39
【问题描述】:
我想通过单击相关按钮来删除行。数据表是有效的,我可以使用一些基本功能,如在数据表中排序和搜索,但是当我单击按钮时它只是简单地说未定义的错误:
供您参考,我正在使用数据表 1.10 和 jquery 1.10.2
代码:
<table cellpadding="0" cellspacing="0" border="0" class="row-border" id="table">
<thead>
<th>Video ID</th>
<th>Filename</th>
<th>Action</th>
</thead>
<tbody>
<td>1</td>
<td>ABCD</td>
<td><input type='button' name='deleteBtn' value='Delete' />
</tbody>
<tfoot>
<tr>
<th>Video ID</th>
<th>Filename</th>
<th>Action</th>
</tr>
</tfoot>
</table>
<script src="jquery.min.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script type="text/javascript">
var table = $('#table').dataTable( {} );
$('#table tbody').on('click',"input[type='button']",function() {
table
.row( $(this).parents('tr') )**
.remove()
.draw();
});
</script>
</body>
</html>
【问题讨论】:
-
把你的脚本放在 $(document).ready(function{});
标签: javascript jquery datatables undefined jquery-datatables