querySelector | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

querySelector

What is the difference between querySelector and querySelectorAll? When is which used? greeting micha

19th Jun 2017, 10:05 PM
micha
micha - avatar
1 Answer
+ 16
Directed from the Mozilla documentation : This specification adds two new methods to any objects implementing the Document, DocumentFragment, or Element interfaces: querySelectorReturns the first matching Element node within the node's subtree. If no matching node is found, null is returned.querySelectorAllReturns a NodeList containing all matching Element nodes within the node's subtree, or an empty NodeList if no matches are found. For reference : https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors
19th Jun 2017, 10:50 PM
Dev
Dev - avatar