Categories
JavaScript Answers

How to use querySelectorAll with multiple conditions with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *