How can I select an element which does not contain a certain child element?

前端 未结 8 1146
抹茶落季
抹茶落季 2020-12-09 09:03

How can I apply jQuery

8条回答
  •  粉色の甜心
    2020-12-09 09:27

    Possibly

    $('.test').filter(function() { return !$(this).children('.example').length; });
    

    This filters out any elements that have any child that matches .example. If you want to filter based on descendants (not just children) that you can substitute .find for .children.

提交回复
热议问题