[ACCEPTED]-Select elements with empty or not-specified attribute-css-selectors
Accepted answer
Late to the party...
... or you could use 1 CSS Selectors and be 10x as fast as both jQuery answers... :)
document.querySelectorAll("input:not([id]), input[id='']");
Basically, don't.
It's not good practice 7 to put all your logic into the selector. It 6 will end up being computationally highly 5 expensive (because the parts need to be 4 parsed out of a string before they are interpreted) and 3 messy. Use the beauty of the filter
method instead:
$('span')
.filter(function(){
return !$(this).attr('cust-attr');
});
This 2 removes all elements where cust-attr
is a non-empty 1 string from the selection.
Why not just select all the SPANs first 1 and then filter the selection down? E.g.
$('span').filter('[cust-attr=""],:not([cust-attr])')
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.