0

What is querySelector in Javascript?

I have seen in many codes that people use querySelector like document.querySelector(). Please help me to understand this

3rd Jun 2021, 4:57 AM
Krushna Katore
Krushna Katore - avatar
1 Answer
+ 1
querySelector select an html element (return first encoutered dom reference) according to the given query string (css selector syntax) argument... querySelectorAll do the same, but return an array-like of all matching elements. conversely to getElement(s) family functions, you're not limited to apply it on 'document' object, but you can also apply it to any html element: then the search is done in all element hierarchy ;)
3rd Jun 2021, 5:35 AM
visph
visph - avatar