Sometimes, we want to use querySelectorAll with multiple conditions with JavaScript.
In this article, we’ll look at how to use querySelectorAll with multiple conditions with JavaScript.
How to use querySelectorAll with multiple conditions with JavaScript?
To use querySelectorAll with multiple conditions with JavaScript, we can call querySelectorAll
with all the selectors separated by a comma.
For instance, we write
const list = document.querySelectorAll("form, p, legend");
to select all form, p, and legend elements in the document.
Conclusion
To use querySelectorAll with multiple conditions with JavaScript, we can call querySelectorAll
with all the selectors separated by a comma.