我有一个脚本,应该检查表中的所有复选框.它首次检查它们,之后它会取消选中它们.但是,当我尝试重新检查它们什么也没有发生.
$('#selectAll').click(function(e){ var table= $(e.target).closest('table'); $('td input:checkBox',table).attr('checked',e.target.checked); });
HTML:
<table> <tr> <th> <input type="checkBox" id="selectAll" /> </th> <th> hi! </th> </tr> <tr> <td> <input type="checkBox" id="1"/> </td> <td> hi! </td> </tr> <tr> <td> <input type="checkBox" id="2"/> </td> <td> hi! </td> </tr> </table>
这是一个行为的小提琴:
为什么点击一次后不起作用?
解决方法
原文地址:https://www.jb51.cc/jquery/179936.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。