Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM Using CSS Queries to Select Page Elements

If i only selecting elements by id, tags and class and do not use document.query selector in developing programs.

If i only select elements by id, tags and class and do not use document.query selector in developing programs. does this make me a bad developer ?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Uche! It absolutely does not make you a bad developer. In fact, using querySelector has a bit of parsing of the DOM going on under the hood which makes it slightly less performant than the others. So if you simply need something to select the id "my-div", it's going to be faster to getElementById('my-div') than the corresponding querySelector. However, you might have a really tricky DOM selection sometimes that requires that you select 3 or 4 things to finally get down to the thing you are after. If that is the case, a querySelector might make your code a bit more concise.

Hope this helps! :sparkles: