DEV Community

Cover image for querySelector() and querySelectorAll()
AjeethKumar_Ramesh
AjeethKumar_Ramesh

Posted on • Edited on

querySelector() and querySelectorAll()

Let me explain the most basics of querySelector() by name.

Don't skip while reading these lines

$-CREATIVE EXPLANATION:

Generally querySelector() and querySelectorAll() from same family which is "API".

query: His most popular name is "question", he is a toddler in API family

Selector: She is the mother of our toddler(query), without her(Selector) query don't know how to work or what to do.

If you understand the pretty lines above go ahead to read real concept,

$-SUBJECT:

querySelector(): To get the particular element from your html document,and make fancy using css or you can use it in your js codes, Which only select the first instance of the element.

querySelectorAll(): Only difference between querySelector() and querySelectorAll() is it(querySelectorAll()) can select as many as instances specifically a particular group of elements having same name (.classNames) or by the tags(h1,p,div etc.,)

This is my first blog, I hope it has little fun with explaining concept, //if it has any mistakes feel free to comment.

Top comments (0)