jquery:如果孩子有特定班级?

mat*_*att 6 jquery

我想知道我如何确定一个ul是否有超过2个孩子,如果有两个孩子在这个ul中有两个特定的类...

if($(this).children().length > 2 && $(this).children('.section-title, .active')) {
    $(this).append('<li class="dots">&hellip;</li>');
}
Run Code Online (Sandbox Code Playgroud)

???

kar*_*m79 8

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/