javascriptselectors-apiqueryselector

How to search with querySelector for html-elements that have no id set in the source?


Is this possible with querySelector?

This doesn't work, but gives simply all elements

document.querySelectorAll('*:not([id=""])');

More info: The user can enter his selector into an input field, and it would be nice if such a search for missing id would be possible without using additional checkboxes or settings, but just with the query-selector.


Solution

  • Instead use

    document.querySelectorAll(':not([id])');