且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery:如果有特定班级的孩子?

更新时间:2023-11-29 17:01:40

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>​

演示: http://jsfiddle.net/RtTSM/1/