Professional Documents
Culture Documents
DOM by Talha
DOM by Talha
DOM methods allow programmatic access to the tree; with them one can change the
structure, style or content of a document.
Once an event is triggered, the event handlers get executed.
In HTML DOM (Document Object Model), every element is a node:
JavaScript
Dom acts as an interface between JavaScript and the document itself. This allows the creation
of dynamic web pages,[12] because within a page JavaScript can:
add, change, and remove any of the HTML elements and attributes
change any of the CSS styles
react to all the existing events
create new events
DOM tree structure
A Document Object Model (DOM) tree is a hierarchical representation of an HTML or XML
document. It consists of a root node, which is the document itself, and a series of child nodes
that represent the elements, attributes, and text content of the document. Each node in the
tree has a parent node, except for the root node, and can have multiple child nodes.
It is a programming interface that allows us to create, change, or remove elements from the
document. Web page, can be modified with a scripting language such as JavaScript. We can also
add events to these elements to make our page more dynamic.
The DOM views an HTML document as a tree of nodes. A node represents an HTML element.
Our document is called the root node and contains one child node which is the <html> element.
The <html> element contains two children which are the <head> and <body> elements.
Both the <head> and <body> elements have children of their own’s.