Where might you have seen our work?Small places create combinations, but crosses that occur cannot provide many combinations. So be careful in making justifications, especially SEO.
What is DOM? Definition, Properties, and How It Works
Last updated: Sep 20, 2022
The Importance of Using DOM
After understanding what DOM is and the importance of using DOM in creating a website, then you also need to know what DOM properties are.
The properties in the DOM are used to access and modify HTML documents. To give you a better understanding, here are the properties in the DOM:
- Window Object - the object in the browser that is at the top of the hierarchy. This object is automatically created by the browser and is used to access all properties in the browser.
- Document Object - an HTML document that has been loaded into the window. This object has several properties related to other objects. With this object, the content on the website can be accessed as well as modified. If you want to access an element in HTML, the property you have to access is the document object.
- Link Object - a DOM property that represents the link tags in an HTML document.
- Anchor Object - a DOM property that represents a href tag in an HTML document.
- Form Object - a DOM property that represents form tags in HTML documents.
- Form Control Elements - DOM properties used to set elements on a form such as text fields, buttons, checkboxes, and so on.
How DOM Works
The following are some examples of using the DOM in accessing and manipulating HTML documents on a website:
How to Fetch HTML Elements
There are several ways to get HTML elements with the DOM:
How to Change HTML Elements
- element.innerHTML: Used to change the content of the HTML element.
- element.attribute: Used to change the value of an attribute in an HTML element.
- element.style.property: Used to change the style of HTML or CSS elements.
How to Add or Remove HTML Elements
- document.createElement(element): Used to create a new HTML element.
- document.removeChild(element): Used to remove HTML elements.
- document.appendChild(element): Used to add HTML elements.
- document.replaceChild(new, old): Used to replace the old HTML elements with the new ones.
WDYT, you like my article?