使用jquery禁用表内的所有复选框 [英] Disable all check boxes inside a table with jquery
本文介绍了使用jquery禁用表内的所有复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在点击同一个表内的超链接时禁用表格单元格内的所有复选框。
我使用以下jQuery代码来选择所有复选框嵌套在表中。
$ el = $(this).parents ')[0] .children('input [type =checkbox]');
$($ el).attr('checked',true);
由于某种原因,这段代码无效。
任何人都可以告诉我如何解决这个问题?
解决方案
<$ c $ p> 'table input [type = checkbox]')。attr('disabled','true');
如果您有表格的ID
$('table#ID input [type = checkbox]')。attr('disabled','true');
I need to disable all the check boxes inside a table cell when clicking on a hyperlink inside the same table.
I'm using the following jquery code to select all the check boxes nested inside the table.
$el = $(this).parents('table:eq(0)')[0].children('input[type="checkbox"]');
$($el).attr('checked', true);
For some reason this piece of code is not working.
Can anyone show me how to fix it?
解决方案
$('table input[type=checkbox]').attr('disabled','true');
if you have an id for the table
$('table#ID input[type=checkbox]').attr('disabled','true');
这篇关于使用jquery禁用表内的所有复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文