What is DOM
The document object Model (DOM) represents the full HTML document. When an HTML document is loaded within the browser, it becomes a document object. The root element represents the HTML document, its properties, and its methods. With the assistance of a document object, we will add dynamic content to our web page.
In another word, the way a document’s content is accessed and modified is the Document Object Model or DOM. The objects are organized in a hierarchy. Web document objects are applied in this hierarchical data structure.
- Window object: It is at the top of the hierarchy. It’s the utmost element of the object hierarchy.
- Document Object: Every HTML document becomes a Document object when it is loaded in windows. Contents of the page reside in the documents.
- Form object: The shape object enclosed within the <form>…</form> tags
- Form control elements: All the elements defined for that object such as text fields, buttons, radio buttons, and checkboxes, are contained in the shape object.
Example 1: The getElementById() using id is used to access elements and attributes. The innerHTML is used to access the content of an element.
Example 2: The getElementsByTagName() method will return an array of all the items with the same tag name. Elements and attributes are accessed using the tag name.
Please Login to comment...