Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有简单的反转方法
document.querySelectorAll(selector)
换句话说,一种方法可以给我文档中与选择器不匹配的所有元素?
selector只是一个 CSS 选择器,所以你可以使用:not()选择器:
selector
document.querySelectorAll(":not(.myClass)");