jQuery "Does not have attribute" selector?
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!
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).
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])')
ReferenceURL : https://stackoverflow.com/questions/12731428/jquery-does-not-have-attribute-selector
'itsource' 카테고리의 다른 글
장고 버전 및 데이터베이스 지원(MariaDB) (0) | 2023.07.26 |
---|---|
반환된 데이터의 최대 크기 (0) | 2023.07.26 |
각도 캐스트 선택 값을 int로 (0) | 2023.07.26 |
시스템 호출 대 함수 호출 (0) | 2023.07.26 |
Linux 입력 장치에서 키 액세스 (0) | 2023.07.26 |