How to exclude specific class names in querySelectorAll()?

后端 未结 3 1137
悲哀的现实
悲哀的现实 2021-02-05 00:50

How can I exclude tag elements that have a specific class name?




document.querySelectorAll(\'span         


        
3条回答
  •  一个人的身影
    2021-02-05 01:05

    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.

提交回复
热议问题