JavaScript Introduction | Document Object Model | DOM Concepts
What is the Document Object Model (DOM)?
The Document Object Model (DOM) is a type of interface for accessing XML or HTML documents.
This object model defines every element in a document and provides ways to access each element.
JavaScript can use this object model to do the following.
- JavaScript can add new HTML elements or attributes.
- JavaScript can remove existing HTML elements or attributes.
- JavaScript can change every HTML element in an HTML document.
- JavaScript can change every HTML attribute in an HTML document.
- JavaScript can change every CSS style in an HTML document.
- JavaScript can add new HTML events to an HTML document.
- JavaScript can respond to every HTML event in an HTML document.
Types of DOM
The W3C DOM standard is divided into three models.
- Core DOM: DOM model for all document types
- HTML DOM: DOM model for HTML documents
- XML DOM: DOM model for XML documents
HTML DOM
The HTML DOM defines a standardized way to manipulate and access HTML documents. Every HTML element can be accessed through the HTML DOM.
XML DOM
The XML DOM defines a standardized way to access and handle XML documents. Every XML element can be accessed through the XML DOM.