JavaScript JavaScript and the DOM The Browser Environment Recap

Rushabha Jain
Rushabha Jain
Full Stack JavaScript Techdegree Student 10,846 Points

DOM 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
Jamie Reardon
Front End Web Development Techdegree Graduate 18,941 Points

DOM 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.

Jamie Reardon
Jamie Reardon
Front End Web Development Techdegree Graduate 18,941 Points

Yes 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.