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
Ben Os20,008 Points
How to connect id and class in document.querySelector ?
Say I want to target an element that has BOTH id and class with querySelector, to later manipulate it,
How can I target the element with this combination?
Owa Aquino19,277 Points
I think there's no way doing this in the query selector and even in your css style sheet.
And if ever it's possible this would be a bad practice.
The purpose of using ID selector is selecting a single element that is unique, while using Class selector is selecting multiple elements with the same qualities. By selecting both ID and Class at the same time it would be difficult for the browser to select a specific elements, it will always return multiple elements (if somehow it's posible to select both Class and ID in the query selectors).
This is only my opinion though, Hope this helps.