Select element unless it has an ancestor of a given class using just a selector

后端 未结 5 935
孤街浪徒
孤街浪徒 2021-01-03 23:11

Suppose I have the following HTML:

  • One
  • Two
5条回答
  •  庸人自扰
    2021-01-03 23:32

    I think this solution looks a little nicer, but there's a bit of controversy on the API comments about speed differences.

    $("li").not(".foo li")
    

    fiddle

提交回复
热议问题