admin管理员组文章数量:1134556
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 have that attribute, I get an error - my code is:
$('.funding-plan-container[!data-timestamp]')
Is there a "does not have attribute" selector in jQuery?
For reference, the use case here is that any div that does not have a timestamp attribute was not added dynamically, and hence is useful.
Thanks!
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 have that attribute, I get an error - my code is:
$('.funding-plan-container[!data-timestamp]')
Is there a "does not have attribute" selector in jQuery?
For reference, the use case here is that any div that does not have a timestamp attribute was not added dynamically, and hence is useful.
Thanks!
Share Improve this question asked Oct 4, 2012 at 16:13 HarryHarry 4,8357 gold badges40 silver badges70 bronze badges3 Answers
Reset to default 253Use 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).
You can filter the selector by using .not() or :not() selector.
$('.funding-plan-container:not([data-timestamp])').
OR
$('.funding-plan-container').not('[data-timestamp]')
Try it with the :not()
pseudo-class selector: http://api.jquery.com/not-selector/
$('.funding-plan-container:not([data-timestamp])')
本文标签: javascriptjQuery quotDoes not have attributequot selectorStack Overflow
版权声明:本文标题:javascript - jQuery "Does not have attribute" selector? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736821904a1954322.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论