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!
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
Peter Huang5,426 Points
Use querySelector / querySelectorAll only
I've used almost all for " querySelector / querySelectorAll " only and it works.
Would this be a good practice or should I be strictly using Sibling / Child in future for projects?
Honestly it depends on the situation. Using
querySelectorAll are wonderful when you have easily identifiable elements (i.e. with a class, id, or specific tag name) to import. Being able to traverse the DOM is important for when you don't have an easy identifier for an element(s) that you want to interact with. Another good example of when to use traversal over identification could be when you want to interact with an element in a specific position without having to add a class or id that specifies when the element is in that position.
Hope this helps!