SlideShare a Scribd company logo
DOCUMENT AND ITS
ASSOCIATED OBJECTS
THE HTML DOM DOCUMENT OBJECT
document, Link, Area, Anchor, Image, Applet, Layer
HTML DOM NODES
 In the HTML DOM (Document Object Model), everything is a node:
 The document itself is a document node
 All HTML elements are element nodes
 All HTML attributes are attribute nodes
 Text inside HTML elements are text nodes
 Comments are comment nodes
THE HTML DOM (DOCUMENT OBJECT MODEL)
THE DOCUMENT OBJECT
 When an HTML document is loaded into a web browser, it becomes a document object.
 The document object is the root node of the HTML document and the "owner" of all
other nodes:
(element nodes, text nodes, attribute nodes, and comment nodes).
 The document object provides properties and methods to access all node objects, from
within JavaScript.
 Tip: The document is a part of the Window object and can be accessed as
window.document.
JAVASCRIPT HAS ALL THE POWER
 With the object model, JavaScript gets all the power it needs to create
dynamic HTML:
 JavaScript can change all the HTML elements in the page
 JavaScript can change all the HTML attributes in the page
 JavaScript can change all the CSS styles in the page
 JavaScript can remove existing HTML elements and attributes
 JavaScript can add new HTML elements and attributes
 JavaScript can react to all existing HTML events in the page
 JavaScript can create new HTML events in the page
WHAT IS THE HTML DOM?
 The HTML DOM is a standard object model and programming
interface for HTML. It defines:
 The HTML elements as objects
 The properties of all HTML elements
 The methods to access all HTML elements
 The events for all HTML elements
 In other words: The HTML DOM is a standard for how to get, change,
add, or delete HTML elements.
JAVASCRIPT - HTML DOM METHODS
 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.
EXAMPLE
<!DOCTYPE html>
<html>
<body>
<h1>My First Page</h1>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>
</body>
</html>
DOM METHODS & PROPERTIES
 The getElementById Method
 The most common way to access an HTML element is to use the id of the element.
 In the example above the getElementById method used id="demo" to find the
element.
 The innerHTML Property
 The easiest way to get the content of an element is by using
the innerHTML property.
 The innerHTML property is useful for getting or replacing the content of HTML
elements.
DOMPROPERTIES
Property Description
document.anchors Returns all <a> elements that have a name attribute
document.applets Returns all <applet> elements (Deprecated in HTML5)
document.body Returns the <body> element
document.cookie Returns the document's cookie
document.doctype Returns the document's doctype
document.documentElement Returns the <html> element
document.documentMode Returns the mode used by the browser
document.documentURI Returns the URI of the document
document.domain Returns the domain name of the document server
document.domConfig Obsolete. Returns the DOM configuration
document.embeds Returns all <embed> elements
document.forms Returns all <form> elements
document.head Returns the <head> element
document.images Returns all <img> elements
document.implementation Returns the DOM implementation
document.inputEncoding Returns the document's encoding (character set)
document.lastModified Returns the date and time the document was updated
document.links Returns all <area> and <a> elements that have a href attribute
document.readyState Returns the (loading) status of the document
document.referrer Returns the URI of the referrer (the linking document)
document.scripts Returns all <script> elements
document.strictErrorChecking Returns if error checking is enforced
document.title Returns the <title> element
document.URL Returns the complete URL of the document
DOM METHODS- FINDING HTML
ELEMENTS
Method Description
document.getElementById(id) Find an element by element id
document.getElementsByTagName(na
me)
Find elements by tag name
document.getElementsByClassName(n
ame)
Find elements by class name
DOCUMENT.BODY
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
alert(“Hi”);
</script>
</body>
</html>
DOCUMENT.BODY
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
alert(document.body.innerHTML);
</script>
</body>
</html>
DOCUMENT.ANCHORS
<!DOCTYPE html>
<html>
<body>
<p>
<a href="/html/default.asp">HTML</a>
<br>
<a href="/css/default.asp">CSS</a>
</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Number of links: " + document.links.length;
</script>
</body>
</html>
DOCUMENT.ANCHORS
<!DOCTYPE html>
<html>
<body>
<a name="html">HTML Tutorial</a><br>
<a name="css">CSS Tutorial</a><br>
<a name="xml">XML Tutorial</a><br>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Number of anchors are: " + document.anchors.length;
</script>
</body>
</html>
DOCUMENT.IMAGES
<!DOCTYPE html>
<html>
<body>
<img src="pic_htmltree.gif">
<img src="pic_navigate.gif">
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"Number of images: " + document.images.length;
</script>
</body>
</html>

More Related Content

What's hot (20)

PDF
Html5 appunti.0
orestJump
 
PDF
Javascript
orestJump
 
PPT
Javascript: Ajax & DOM Manipulation v1.2
borkweb
 
PDF
Javascript
Rajavel Dhandabani
 
PDF
Introduzione JQuery
orestJump
 
PDF
Html tags describe in bangla
Amrita Chandra Das
 
PPSX
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
PPTX
Web designing unit 4
Dr. SURBHI SAROHA
 
PDF
Intro to jQuery
Shawn Calvert
 
PPTX
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Ayes Chinmay
 
PPT
jQuery Beginner
kumar gaurav
 
PPTX
jQuery PPT
Dominic Arrojado
 
PPT
JavaScript & Dom Manipulation
Mohammed Arif
 
PPTX
jQuery from the very beginning
Anis Ahmad
 
PPT
Java script -23jan2015
Sasidhar Kothuru
 
PPT
Think jQuery
Ying Zhang
 
PDF
Intro to Javascript and jQuery
Shawn Calvert
 
PPTX
Introduction to JQuery
Muhammad Afzal Qureshi
 
PPTX
Introduction to jQuery
Gunjan Kumar
 
Html5 appunti.0
orestJump
 
Javascript
orestJump
 
Javascript: Ajax & DOM Manipulation v1.2
borkweb
 
Javascript
Rajavel Dhandabani
 
Introduzione JQuery
orestJump
 
Html tags describe in bangla
Amrita Chandra Das
 
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
Web designing unit 4
Dr. SURBHI SAROHA
 
Intro to jQuery
Shawn Calvert
 
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Ayes Chinmay
 
jQuery Beginner
kumar gaurav
 
jQuery PPT
Dominic Arrojado
 
JavaScript & Dom Manipulation
Mohammed Arif
 
jQuery from the very beginning
Anis Ahmad
 
Java script -23jan2015
Sasidhar Kothuru
 
Think jQuery
Ying Zhang
 
Intro to Javascript and jQuery
Shawn Calvert
 
Introduction to JQuery
Muhammad Afzal Qureshi
 
Introduction to jQuery
Gunjan Kumar
 

Similar to FYBSC IT Web Programming Unit III Document Object (20)

DOCX
DOM(Document Object Model) in javascript
Rashmi Mishra
 
PDF
Dom
soumya
 
PPTX
Document object model
Amit kumar
 
PPTX
Dom date and objects and event handling
smitha273566
 
PPTX
Digital Marketing Company
Payal9675
 
PPTX
DOM and Events
Julie Iskander
 
PPTX
WEB TECHNOLOGY Unit-4.pptx
karthiksmart21
 
PDF
Java script
Yoga Raja
 
PPTX
Javascript part 2 DOM.pptx
deepa339830
 
PPTX
Understanding the dom by Benedict Ayiko
Damalie Wasukira
 
PPT
Automating Ievb
nageshreddy15
 
PPTX
Electronics is a scientific and engineering discipline that studies and appli...
JANARTHANANS22
 
PPT
DOM Quick Overview
Signure Technologies
 
PPTX
2.java script dom
PhD Research Scholar
 
PPTX
DOM (document Object Model) in java Script).pptx
powerofthehelios
 
PDF
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
PPTX
Introduction to java script, how to include java in HTML
backiyalakshmi14
 
DOM(Document Object Model) in javascript
Rashmi Mishra
 
Dom
soumya
 
Document object model
Amit kumar
 
Dom date and objects and event handling
smitha273566
 
Digital Marketing Company
Payal9675
 
DOM and Events
Julie Iskander
 
WEB TECHNOLOGY Unit-4.pptx
karthiksmart21
 
Java script
Yoga Raja
 
Javascript part 2 DOM.pptx
deepa339830
 
Understanding the dom by Benedict Ayiko
Damalie Wasukira
 
Automating Ievb
nageshreddy15
 
Electronics is a scientific and engineering discipline that studies and appli...
JANARTHANANS22
 
DOM Quick Overview
Signure Technologies
 
2.java script dom
PhD Research Scholar
 
DOM (document Object Model) in java Script).pptx
powerofthehelios
 
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Introduction to java script, how to include java in HTML
backiyalakshmi14
 
Ad

More from Arti Parab Academics (20)

PPTX
COMPUTER APPLICATIONS Module 4.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 1 HPSY - Copy.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 5.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 1 CAH.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 3.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 1-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 1-Chapter 2.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 4.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 1 HPSY - Copy.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 5.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 1 CAH.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 3.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 2.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 1-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 1-Chapter 2.pptx
Arti Parab Academics
 
Ad

Recently uploaded (20)

PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Horarios de distribución de agua en julio
pegazohn1978
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 

FYBSC IT Web Programming Unit III Document Object

  • 1. DOCUMENT AND ITS ASSOCIATED OBJECTS THE HTML DOM DOCUMENT OBJECT document, Link, Area, Anchor, Image, Applet, Layer
  • 2. HTML DOM NODES  In the HTML DOM (Document Object Model), everything is a node:  The document itself is a document node  All HTML elements are element nodes  All HTML attributes are attribute nodes  Text inside HTML elements are text nodes  Comments are comment nodes
  • 3. THE HTML DOM (DOCUMENT OBJECT MODEL)
  • 4. THE DOCUMENT OBJECT  When an HTML document is loaded into a web browser, it becomes a document object.  The document object is the root node of the HTML document and the "owner" of all other nodes: (element nodes, text nodes, attribute nodes, and comment nodes).  The document object provides properties and methods to access all node objects, from within JavaScript.  Tip: The document is a part of the Window object and can be accessed as window.document.
  • 5. JAVASCRIPT HAS ALL THE POWER  With the object model, JavaScript gets all the power it needs to create dynamic HTML:  JavaScript can change all the HTML elements in the page  JavaScript can change all the HTML attributes in the page  JavaScript can change all the CSS styles in the page  JavaScript can remove existing HTML elements and attributes  JavaScript can add new HTML elements and attributes  JavaScript can react to all existing HTML events in the page  JavaScript can create new HTML events in the page
  • 6. WHAT IS THE HTML DOM?  The HTML DOM is a standard object model and programming interface for HTML. It defines:  The HTML elements as objects  The properties of all HTML elements  The methods to access all HTML elements  The events for all HTML elements  In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
  • 7. JAVASCRIPT - HTML DOM METHODS  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.
  • 8. EXAMPLE <!DOCTYPE html> <html> <body> <h1>My First Page</h1> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Hello World!"; </script> </body> </html>
  • 9. DOM METHODS & PROPERTIES  The getElementById Method  The most common way to access an HTML element is to use the id of the element.  In the example above the getElementById method used id="demo" to find the element.  The innerHTML Property  The easiest way to get the content of an element is by using the innerHTML property.  The innerHTML property is useful for getting or replacing the content of HTML elements.
  • 10. DOMPROPERTIES Property Description document.anchors Returns all <a> elements that have a name attribute document.applets Returns all <applet> elements (Deprecated in HTML5) document.body Returns the <body> element document.cookie Returns the document's cookie document.doctype Returns the document's doctype document.documentElement Returns the <html> element document.documentMode Returns the mode used by the browser document.documentURI Returns the URI of the document document.domain Returns the domain name of the document server document.domConfig Obsolete. Returns the DOM configuration document.embeds Returns all <embed> elements document.forms Returns all <form> elements document.head Returns the <head> element document.images Returns all <img> elements document.implementation Returns the DOM implementation document.inputEncoding Returns the document's encoding (character set) document.lastModified Returns the date and time the document was updated document.links Returns all <area> and <a> elements that have a href attribute document.readyState Returns the (loading) status of the document document.referrer Returns the URI of the referrer (the linking document) document.scripts Returns all <script> elements document.strictErrorChecking Returns if error checking is enforced document.title Returns the <title> element document.URL Returns the complete URL of the document
  • 11. DOM METHODS- FINDING HTML ELEMENTS Method Description document.getElementById(id) Find an element by element id document.getElementsByTagName(na me) Find elements by tag name document.getElementsByClassName(n ame) Find elements by class name
  • 14. DOCUMENT.ANCHORS <!DOCTYPE html> <html> <body> <p> <a href="/html/default.asp">HTML</a> <br> <a href="/css/default.asp">CSS</a> </p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Number of links: " + document.links.length; </script> </body> </html>
  • 15. DOCUMENT.ANCHORS <!DOCTYPE html> <html> <body> <a name="html">HTML Tutorial</a><br> <a name="css">CSS Tutorial</a><br> <a name="xml">XML Tutorial</a><br> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Number of anchors are: " + document.anchors.length; </script> </body> </html>
  • 16. DOCUMENT.IMAGES <!DOCTYPE html> <html> <body> <img src="pic_htmltree.gif"> <img src="pic_navigate.gif"> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Number of images: " + document.images.length; </script> </body> </html>