检查一个复选框,检查所有的复选框 [英] checking one checkbox checks all the checkbox
本文介绍了检查一个复选框,检查所有的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要检查所有其他复选框,如果一个复选框被选中。我的code
I want to check all the other checkboxes if one checkbox is checked. My code
<tr>
<td class="small"><asp:CheckBox ID="chkReportModuleName" runat="server" name="report"></asp:CheckBox></td>
<td class="particulrs"></td>
<td class="small"><asp:CheckBox ID="chkReportAdd" runat="server" name="reports"></asp:CheckBox></td>
<td class="small"><asp:CheckBox ID="chkReportEdit" runat="server" name="reports"></asp:CheckBox></td>
<td class="small"><asp:CheckBox ID="chkReportDelete" runat="server" name="reports"></asp:CheckBox></td>
<td class="small"><asp:CheckBox ID="chkReportView" runat="server" name="reports"></asp:CheckBox></td>
<td class="small"><asp:CheckBox ID="chkReportPrint" runat="server" name="reports"></asp:CheckBox></td>
<td class="othr"><span><input type="checkbox" id="chkReportActivity1" name="reports" /></span></td>
</tr>
在该复选框命名report.I要检查所有的复选框名为报告的检查。
On check of the checkbox named report.I want to check all the checkboxes with the name reports.
有人可以帮助我?
谢谢
Can someone please help me with this? Thanks
推荐答案
使用这样的:
$(function(){
// add multiple select / deselect functionality
$("#selectall").click(function () {
$('.case').attr('checked', this.checked);
});
});
其中, #selectall
是报告复选框的ID和。病例
是所有的的CssClass chekboxes你想获得的点击选择 #selectall
Where #selectall
is the id of Your "report" checkbox and .case
is the cssclass for all the chekboxes you want to get selected on clicking #selectall
您也可以使用托
函数代替 ATTR
的jQuery的较新版本
You can also use prop
function instead of attr
for newer version of jquery
这篇关于检查一个复选框,检查所有的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文