How can I exclude tag elements that have a specific class name?
JavaScript
x
5
1
<span class="test" />
2
<span class="test asd" />
3
4
document.querySelectorAll('span.test'); //how to exclude all spans with "asd" as class name?
5
Advertisement
Answer
Use :not
CSS pseudo-class:
JavaScript
1
2
1
document.querySelectorAll('span.test:not(.asd)');
2