动态添加复选框

编程入门 行业动态 更新时间:2024-10-25 00:30:46
本文介绍了动态添加复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使表格上的复选框可以检查?我有下面的代码通过使用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更新

更多推荐

动态添加复选框

本文发布于:2023-10-12 23:19:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复选框   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!