How can I exclude tag elements that have a specific class name?
document.querySelectorAll(\'span
Use :not CSS pseudo-class:
document.querySelectorAll('span.test:not(.asd)');
Use the CSS's negation pseudo-selector, :not():
document.querySelectorAll('span.test:not(.asd)');
The negation pseudo-class,
:not(X)
, is a functional notation taking a simple selector (excluding the negation pseudo-class itself) as an argument. It represents an element that is not represented by its argument.
Element by tagName and ignore or exclude element that have a specific class:
document.querySelectorAll(`svg,div:not([class*="background"]`)