jQuery “Does not have attribute” selector?

前端 未结 3 1404
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 08:09

I can find a div that has an attribute like so:

$(\'.funding-plan-container[data-timestamp]\')

But if I try to find a div that does not hav

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 08:18

    Use the :not() selector.

    $('.funding-plan-container:not([data-timestamp])')
    

    This, by the way, is a valid Selectors API selector, so it isn't specific to jQuery. It'll work with querySelectorAll() and in your CSS (given browser support).

提交回复
热议问题