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 Treehouse Club - MASH MASH - JavaScript Handle Submission and Event Handler Functions

Question Any Help Will Be Appreciated.

When we use this syntax(document.querySelector) and we capture an ID what can you do if you capture an ID. Will it be doing something important to the program?

1 Answer

Snir Lugassy
Snir Lugassy
1,824 Points

querySelector is querying the document based on what you are looking for, and return an array of matched elements, for example, you can look for the buttons with class "cool button".

HTML ID attribute should be unique, therefore it is supposed to return an array with 1 item.

After you "capture" this element you can manipulate the DOM (if you don't understand the DOM i would recommend to learn it as deep as you can).