jQuery “Does not have attribute” selector?

前端 未结 3 1401
被撕碎了的回忆
被撕碎了的回忆 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).

    0 讨论(0)
  • 2020-12-13 08:19

    You can filter the selector by using .not() or :not() selector.

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

    OR

    $('.funding-plan-container').not('[data-timestamp]') 
    
    0 讨论(0)
  • 2020-12-13 08:38

    Try it with the :not() pseudo-class selector: http://api.jquery.com/not-selector/

    $('.funding-plan-container:not([data-timestamp])')
    
    0 讨论(0)
提交回复
热议问题