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 trialRushabha Jain
Full Stack JavaScript Techdegree Student 11,141 PointsDOM or HTML Content?
Does document object refers to HTML content or DOM to select and manipulate elements? Like will 'getElementById' get the element from HTML content or will it look in the DOM to retrieve element.
1 Answer
Jamie Reardon
Treehouse Project ReviewerDOM stands for document object model which is a global object to the browser. Above that, you have the window object.
The getElementById is a method that belongs to the document object. It is used to select an element on a page that has the matching id attribute value. It therefore returns the element and not the html content.
Rushabha Jain
Full Stack JavaScript Techdegree Student 11,141 PointsRushabha Jain
Full Stack JavaScript Techdegree Student 11,141 Points@Jamie Reardon so, DOM is same as document object in javascript. correct?
Jamie Reardon
Treehouse Project ReviewerJamie Reardon
Treehouse Project ReviewerYes it is the same thing. You can access properties and methods through JavaScript using the document object. E.g. the write() method writes to the page.