如何使表格上的复选框可以检查?我有下面的代码通过使用jquery函数动态添加复选框。下面的代码可以动态添加复选框,但问题是函数添加的复选框无法检查(禁用)。
how to make the checkbox on the table can be checked? I've the code below to add the checkbox dynamically by using a jquery function. The code below succeed to add the checkbox dynamically, but the problem is the checkbox added by the function can't be checked (disabled).
<table id="detail"> <tr> <td><input type="checkbox" id="cb" name="cb[]"></td> </tr> </table>这是用于添加行的按钮:
This is the button to add the row:
<input type="button" id="addRow" value="ADD ROW" />这是我有的jquery函数:
And this is the jquery function I have:
<script type="text/javascript"> $(document).ready(function() { $("#addRow").click(function() { $('#detail tbody>tr:last').clone(true).insertAfter('#detail tbody>tr:last'); }); }); </script>任何人都可以帮助您的代码?感谢...:)
Anyone can help for the code? Thanks... :)
推荐答案请先修正javascript函数!
Please first correct the javascript function !
$(document).ready(function() { $("#addRow").click(function() { $('#detail tbody>tr:last').clone(true).insertAfter('#detail tbody>tr:last'); }); });您的代码适用于我的意思是复选框被选中(只有当你勾选最后一个复选框,将克隆它)
And your code works for me means the checkbox is checked (only if you tick last checkbox then your code will clone it)
查看我的 jsfiddle 或 jsfiddle更新
更多推荐
动态添加复选框
发布评论