我试图禁用jquery中的所有元素的所有子元素。@H_403_3@
打电话@H_403_3@
$('#id_of_an_element').children().do(function(){ do_something; });
递归地调用一个元素的所有子元素,或者只对an_element的所有直接后代执行do_something?@H_403_3@
帮助是赞赏,@H_403_3@
玩笑@H_403_3@
解决方法
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().@H_403_3@
http://api.jquery.com/children/@H_403_3@
如果您想在任何嵌套级别对所有后代采取行动,可以执行此操作:@H_403_3@
$('#id_of_an_element').find('*').attr('disabled',true);
或使用后代选择器:@H_403_3@
$('#id_of_an_element *').attr('disabled',true);