What is Document Object Model(DOM) ? How JS interacts with DOM

In this tutorial of JavaScript fundamentals, we will study and understand the concept of Document Object Model also known as DOM.

Document Object Model(DOM) –

document object model - DOM in JavaScript

The Document Object Model (DOM) defines the logical structure of documents and the way a document is accessed and manipulated.

The name “Document Object Model” was chosen because it is an “object model” is used in the traditional object oriented design sense: documents are modeled using objects, and the model encompasses not only the structure of a document, but also the behavior of a document and the objects of which it is composed. In other words, the nodes in the above diagram do not represent a data structure, they represent objects, which have functions and identity.

JavaScript interacts with HTML document indirectly by interacting with the DOM. With the document object model, JavaScript gets all the power it needs to create dynamic HTML:

  • JavaScript can change all the HTML elements in the page
  • JavaScript can change all the HTML attributes in the page
  • JavaScript can change all the CSS styles in the page
  • JavaScript can remove existing HTML elements and attributes
  • JavaScript can add new HTML elements and attributes
  • JavaScript can react to all existing HTML events in the page
  • JavaScript can create new HTML events in the page
Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *