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 trialRhysRhys Dyson
435 PointsDOM Hierarchy - Top Levels
So I understand that the DOM hierarchy works exactly like the HTML/CSS Box model for selecting elements with JavaScript.
At the top of the tree, is the document. Is the document the entire project, or just the index.html file (or the current active page).
Are we able to select and specify documents by HTML page using the document selector. Is that the importance of understanding the DOM model and structure, to specify code for different pages and sections or our projects?
Example:
- Create a conditional to only run on a specific page/document (although in most cases, for the web, you would just include the script in that specific page's head/footer). But maybe not so much for an app?
1 Answer
Steven Parker
231,275 PointsThe DOM describes the organization of each individual page of HTML code. So the "document" would be the current active page.