“All but not” jQuery selector

后端 未结 7 1378
谎友^
谎友^ 2020-12-05 16:44

I can select (using jQuery) all the divs in a HTML markup as follows:

$(\'div\')

But I want to exclude a particular div (say h

7条回答
  •  生来不讨喜
    2020-12-05 17:42

    $("div:not(#myid)")
    

    [doc]

    or

    $("div").not("#myid")
    

    [doc]

    are main ways to select all but one id

    You can see demo here

提交回复
热议问题