[英]How do I select all disabled decendants using jQuery
I want to be able to select all disabled decandants of a given element, in my particular instance a table cell and then enable them. 我希望能够选择给定元素的所有禁用的decantant,在我的特定实例中是一个表格单元格,然后启用它们。
NOTE that there may be elements that are not "inputs" 注意,有些元素可能不是“输入”
I have tired the following with no success 我已经厌倦了以下工作,但没有成功
$("#myCell [disabled='disabled']").removeAttr('disabled')
and 和
$("#myCell [disabled='disabled']").attr('disabled','')
Try: 尝试:
$('#myCell :input:disabled').removeAttr('disabled');
The :input
selector is going to select all input elements, and the :disabled
selector is going to select elements that are disabled. :input
选择器将选择所有输入元素,而:disabled
选择器将选择禁用的元素。 You could probably just have the :disabled
selector but it doesn't hurt to have both and is probably marginally faster to do so. 您可能只拥有
:disabled
选择器,但同时拥有这两个选择并没有什么坏处,这样做的速度可能稍快。
My solution: 我的解决方案:
$("#myCell *[disabled='disabled']").removeAttr("disabled");
This * selector means 'all elements' *选择器表示“所有元素”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.