我想知道我如何确定一个ul是否有超过2个孩子,如果有两个孩子在这个ul中有两个特定的类...
if($(this).children().length > 2 && $(this).children('.section-title, .active')) {
$(this).append('<li class="dots">…</li>');
}
Run Code Online (Sandbox Code Playgroud)
???
var $ul = $('ul');
if($ul.find("li").length > 2 && $ul.find('.active, .inactive').length == 2) {
alert('yes, it is this way');
}?
<ul>
<li class="active">Whatever</li>
<li class="inactive">Whatever</li>
<li>Whatever</li>
<li>Whatever</li>
</ul>?
Run Code Online (Sandbox Code Playgroud)
演示:http://jsfiddle.net/RtTSM/1/
| 归档时间: |
|
| 查看次数: |
13702 次 |
| 最近记录: |