jQuery Selectors - where item does not have children with a certain class

后端 未结 4 445
南方客
南方客 2021-01-17 22:39

I want to select list items that are immediate children of #nav, that do not themselves have immediate children with an \'active\' class.

This is what I think it sho

4条回答
  •  半阙折子戏
    2021-01-17 22:50

    You'll need to use jQuery's filter function:

    $('#nav > li').filter(function() { return !($(this).children().is('.active')); })
    

提交回复
热议问题