CodeNewbie Community

loading...

What do querySelectorAll and getElementsBy methods return?

Sean
Portlander addicted to code and coffee.
・1 min read

Calling all CodeNewbies! I've been working on leveling up my JavaScript skills and ran into these two methods. Can you all help me figures our what querySelectorAll and getElementsBy methods return?

'Preciate your help!

Discussion (1)

Collapse
chukwukagideon profile image
Chukwukagideon

Well to the best of my knowledge, querySelectorAll returns all selectors that is being targeted (e.g query selector all(".hello") selects all elements with the class "hello".
haven't really come across getElementsBy methods before, but I guess its basically targeting all elements with a particular method. But if you meant getElementById - The document.getElementById() method returns the element of specified id.