0% found this document useful (0 votes)
28 views

Document Object Model DOM in JavaScript

Uploaded by

abdotaouil03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Document Object Model DOM in JavaScript

Uploaded by

abdotaouil03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Document

Object Model
(DOM) in
JavaScript
The Document Object Model (DOM) is a programming interface for
HTML documents. It represents the structure of a document as a
tree-like hierarchy, allowing developers to access and manipulate
web page content, structure, and style using JavaScript.
Introduction to the DOM
1 Structure
The DOM represents an HTML document as a tree
structure, where each HTML element is a "node" connected
in a hierarchy, similar to a family tree.

2 Manipulation
It provides a way for programs to dynamically access and
update the content, structure, and style of documents.
How the DOM Works
Root Element
The topmost node is the document object, representing the entire HTML document.

Parent-Child Relationships
Elements can contain other elements, creating a hierarchical structure of parent and child nodes.

Node Types
The DOM includes various node types: elements, text nodes, and attributes.
Accessing the DOM with JavaScript

getElementById querySelector classList


Allows manipulation of an
Retrieves an element by its unique Selects the first element that
element's classes, adding or
ID attribute. matches a specified CSS selector.
removing them dynamically.
Modifying the DOM
Creating Elements

Modifying Content

Removing Elements
Some Examples
getElementById()

querySelector()

classList

You might also like