这可能是一个是/否类型的问题。
我试图禁用jquery中的所有元素的所有子元素。
打电话
$('#id_of_an_element').children().do(function(){ do_something; });
递归地调用一个元素的所有子元素,或者只对an_element的所有直接后代执行do_something?
帮助是赞赏,
玩笑
解决方法
Given a jQuery object that represents
a set of DOM elements,the .children()
method allows us to search through the
immediate children of these elements
in the DOM tree and construct a new
jQuery object from the matching
elements. The .find() and .children()
methods are similar,except that the
latter only travels a single level
down the DOM tree. Note also that like
most jQuery methods,.children() does
not return text nodes; to get all
children including text and comment
nodes,use .contents().
http://api.jquery.com/children/
如果您想在任何嵌套级别对所有后代采取行动,可以执行此操作:
$('#id_of_an_element').find('*').attr('disabled',true);
或使用后代选择器:
$('#id_of_an_element *').attr('disabled',true);