How can I select all the elements on a page that do not have an "id" attribute? What is the selector for this in jQuery?
The id selector uses the id attribute of an HTML element to select a specific element. The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.
You do not need to put ID attribute if it is not required, and you can always add ID attribute whenever required. Keeping only required elements in html will make it easy to read, clean, low on size and hence improves performance and speed.
The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.
The :not CSS pseudo-class can be used to select elements that do not contain a specific class, id, attribute etc.
Negative selector :not([id])
should work. See:
You can use $(':not([id])')
. That should work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With