[ACCEPTED]-Select elements with empty or not-specified attribute-css-selectors

Accepted answer
Score: 14

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='']");


Score: 5

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:

        return !$(this).attr('cust-attr');

This 2 removes all elements where cust-attr is a non-empty 1 string from the selection.

Score: 4

Why not just select all the SPANs first 1 and then filter the selection down? E.g.


More Related questions