Wor*_*sor 2 size each jquery children addclass
我想为每个有2个以上孩子的项添加"任何东西".不幸的是我的代码不起作用,我想我必须定义(这个)并且可能使用每个,但我不知道该怎么做.
这是我的代码:
if ( jQuery('#container .document').children().size() > 2 ) {
jQuery(this).addClass("anything");
}
Run Code Online (Sandbox Code Playgroud)
一个破碎的例子:
您可以使用过滤器将列表限制为具有两个以上子项的元素.
jQuery('#container .document').filter(function() {
return this.children.length > 2; //Use just the regular DOM children property in here
}).addClass("anything");
Run Code Online (Sandbox Code Playgroud)
JSFiddle:http://jsfiddle.net/HHSuM/4/