Let's say I want to find all div
elements and span
inside p
. Is it possible to get all what I want in a single `querySelectorAll" invocation?
Conceptually it should be something like document.querySelectorAll("div | p span")
(if | means or).
Let's say I want to find all div
elements and span
inside p
. Is it possible to get all what I want in a single `querySelectorAll" invocation?
Conceptually it should be something like document.querySelectorAll("div | p span")
(if | means or).
Yes. You can use the same logical operators allowed in CSS:
OR: chain selectors with commas
AND: chain selectors without whitespace
NOT:
:not()
-selector