DOM Manipulation with JS

DOM (Document Object Model) is an in-memory representation of HTML documents. It represents the webpage as a JS object so that JS programs can modify it.

DOM HTML tree

Node tree

These are some of the APIs for DOM manipulation:

HTML DOM methods are actions you can perform (on HTML Elements).

HTML DOM properties are values (of HTML Elements) that you can set or change.

In the DOM, all HTML elements are defined as objects.

The programming interface is the properties and methods of each object.

property is a value that you can get or set (like changing the content of an HTML element).

method is an action you can do (like add or deleting an HTML element).

Example

Add an event listener that fires when a user clicks a button:

document.getElementById("myBtn").addEventListener("click", displayDate);

Leave a comment

Design a site like this with WordPress.com
Get started