SlideShare uma empresa Scribd logo
1 de 27
Agenda
 Evaluation.
 Benefits of DOM.
 DOM Structure and implements.
 XML With DOM.
 HTML With DOM.
 JavaScript with DOM.
 CSS with DOM.
 Q&A
 Where the Document Object Model came from?
 What is Document Object Model ?
Where the Document Object Model came from?
 "browser wars" of the late 1990s between Netscape Navigator
and Microsoft Internet Explorer.
 1996 within Netscape Navigator 2.0
“DOM Level 0" or "Legacy DOM”
 W3C in late 1998 - > 2000 itro.. DOM Level 1 and 2.
 2005, large parts of W3C DOM were well-supported
by common ECMAScript-enabled browsers
What is Document Object Model ?
Document Object Model (DOM), a programming interface
specification being developed by the World Wide Web
Consortium (W3C), lets a programmer create and modify
HTML pages and XML documents as full-fledged program
objects.
In short..
 set of objects/elements
 a structure of how these objects/elements can be combined
 and an interface to access and modify them
Benefits of DOM.
 Read the entire document
 Represents result as a tree
 Lets you search tree
 Lets you modify tree
 Good for reading data/configuration files
 Support in many different languages.
DOM Structure and implements
 Objects are in a hierarchy
 The window is the parent
for a given web page.
 Document is the child with
the objects that are most
commonly manipulated
[CONTINUED]
DOM Tree
The usual parent/child relationship between node
Like any other tree, you can walk this
[CONTINUED]
Referencing Objects
 By their id or name (this is the easiest way, but
you need to make sure a name is unique in the
hierarchy)
 by their numerical position in the hierarchy, by
walking the array that contains them
 by their relation to parent, child, or sibling
(parentNode, previousSibling, nextSibling, firstChild,
lastChild or the childNodes array
What is a Node?
 Element Node – contains an HTML tag
 Text Node – contains text
 Text Nodes are contained in Element Nodes
[CONTINUED]
Nodes Organise the Page
html
head
title
text
“my page”
body
p
text
“This is text
on
my page”
<html>
<head>
<title>My page</title>
</head>
<body>
<p>This is text on my page</p>
</body>
</html>
[CONTINUED]
Adding Some Text To A Page
 Create a new Element
[document.createElement(“p”)]
 Create a Text Node
[document.createTextNode(“Some text.”) ]
 Attach the New Text Node to the New Element
[newNode.appendChild(newText)]
 Find an Existing Element
[document.getElementById(“thisLocation”)]
 Append the New Element to the Existing Element
[docElement.appendChild(newNode)]
[CONTINUED]
Putting the all Steps Together
EXAMPLE - 01
Remove a Node
“To remove a node, we use the element method removeChild (name of node to be removed)”
function remText(location) {
var docElement;
docElement = document.getElementById(location);
docElement.removeChild(docElement.lastChild);
}
[CONTINUED]
Best way to the get Element
 getElementById() allows you to work with elements by
their individual id but often you will want to work with a
group of elements
 getElementsByTagName() allows you to work with
groups of elements. This method returns an array
[CONTINUED]
Where on the Node Tree?
 childNodes
 nodeList = node.childNodes
 firstChild
 reference = node.firstChild
 lastChild
 nextSibling
 parentNode
 previousSibling
[CONTINUED]
Attribute Nodes
 We can get at the attributes of an element through attribute nodes
 Attribute nodes, like text nodes are always contained in element nodes
 We shall look at methods:
 getAttribute()
 setAttribute()
function dispAttribs() {
var messg;
attribs = new Array;
attribs = document.getElementsByTagName("p");
for (i = 0; i < attribs.length; i++) {
messg = attribs[i].getAttribute("className");
alert(messg);
}
}
function chngAttribs() {
var messg;
attribs = new Array;
attribs = document.getElementsByTagName("p");
for (i = 0; i < attribs.length; i++) {
attribs[i].setAttribute("className","jazz");
}
}
[CONTINUED]
XML With DOM
 EXtensible Markup Language (XML) is a meta-language that describes the content of
the document (self-describing data).
 XML does not specify the tag set or grammar of the language
 Media for data interchange
 XML only has container tags
<blah>...</blah> or <blah/>
EXAMPLE-02
HTML With DOM
 We can track any tag with respect its name
and global attribute.
 Use to arrange the XML data in UI.
 Give Action through the event Handler.
 Add and modified the tag with data.
[CONTINUED]
EXAMPLE-03
JavaScript with DOM
 JavaScript Objects Reference
 Browser Objects Reference
 Core DOM Objects Reference
 HTML DOM Objects Reference
EXAMPLE-04
CSS With DOM
 Dynamically we can add inner Style sheet.
 We can also add css class.
EXAMPLE-05
All the HTML in the tag is replaced when
the innerHTML method is used
innerHTML is not part of the DOM – so it
may one day disappear – though it is
universally recognised by browsers
Tags within the innerHTML are not part
of the DOM tree so they cannot be
manipulated
Points to know.
[CONTINUED]
Points to know.
 Understand the nature and structure of the DOM
 Add and remove content from the page
 Access and change element attributes –
including source and class
 Insert markup into a page using innerHTML
 Change style attribute using Javascript
Points to know
 DOM makes all components of a web page
accessible
 HTML elements
 their attributes
 text
 They can be created, modified and removed
with JavaScript
DOM Standards
 W3C www.w3.org/DOM/defines the standards
 DOM Level 3 recommendation
 www.w3.org/TR/DOM-Level-3-Core/
 DOM Level 2 HTML Specification
 www.w3.org/TR/DOM-Level-2-HTML/
 additional DOM functionality specific to HTML,
in particular objects for XHTML elements
Email – amit.kumar@above-inc.com
With Subject
DOM-NTK-Your name.
Document object model

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Dom
Dom Dom
Dom
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Bootstrap Part - 1
Bootstrap Part - 1Bootstrap Part - 1
Bootstrap Part - 1
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts Basics
 
Html
HtmlHtml
Html
 
Jquery
JqueryJquery
Jquery
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
CSS
CSSCSS
CSS
 
Introduction to the DOM
Introduction to the DOMIntroduction to the DOM
Introduction to the DOM
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
Dom
DomDom
Dom
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
HTML CSS JS in Nut shell
HTML  CSS JS in Nut shellHTML  CSS JS in Nut shell
HTML CSS JS in Nut shell
 
CSS
CSSCSS
CSS
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 

Destaque (16)

HTML Block and Inline Elements
HTML Block and Inline ElementsHTML Block and Inline Elements
HTML Block and Inline Elements
 
Ppt url
Ppt urlPpt url
Ppt url
 
Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
Dom Structure in html
Dom Structure in htmlDom Structure in html
Dom Structure in html
 
Html5 Basic Structure
Html5 Basic StructureHtml5 Basic Structure
Html5 Basic Structure
 
XML
XMLXML
XML
 
Quarter 3 tiers
Quarter 3 tiers Quarter 3 tiers
Quarter 3 tiers
 
HTML
HTML HTML
HTML
 
Differences Between Architectures
Differences Between ArchitecturesDifferences Between Architectures
Differences Between Architectures
 
Url
UrlUrl
Url
 
Hotel management notes link
Hotel management notes linkHotel management notes link
Hotel management notes link
 
Url Presentation
Url PresentationUrl Presentation
Url Presentation
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Js ppt
Js pptJs ppt
Js ppt
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for Beginners
 

Semelhante a Document object model

Semelhante a Document object model (20)

Xml
XmlXml
Xml
 
HTML/CSS Lecture 1
HTML/CSS Lecture 1HTML/CSS Lecture 1
HTML/CSS Lecture 1
 
Understanding the dom by Benedict Ayiko
Understanding the dom by Benedict AyikoUnderstanding the dom by Benedict Ayiko
Understanding the dom by Benedict Ayiko
 
Digital Marketing Company
Digital Marketing CompanyDigital Marketing Company
Digital Marketing Company
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document Object
 
Dom structure
Dom structure Dom structure
Dom structure
 
Unit 2 dhtml
Unit 2 dhtmlUnit 2 dhtml
Unit 2 dhtml
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
 
6867389 (1).ppt
6867389 (1).ppt6867389 (1).ppt
6867389 (1).ppt
 
Week 2-intro-html
Week 2-intro-htmlWeek 2-intro-html
Week 2-intro-html
 
HTML and CSS Basics
HTML and CSS BasicsHTML and CSS Basics
HTML and CSS Basics
 
Intr to-html-xhtml-1233508169541646-3
Intr to-html-xhtml-1233508169541646-3Intr to-html-xhtml-1233508169541646-3
Intr to-html-xhtml-1233508169541646-3
 
DITA,Single-source, Multi-channel Publishing
DITA,Single-source, Multi-channel PublishingDITA,Single-source, Multi-channel Publishing
DITA,Single-source, Multi-channel Publishing
 
Automating Ievb
Automating IevbAutomating Ievb
Automating Ievb
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Vskills angular js sample material
Vskills angular js sample materialVskills angular js sample material
Vskills angular js sample material
 
HTML 5
HTML 5HTML 5
HTML 5
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Document object model

  • 1.
  • 2. Agenda  Evaluation.  Benefits of DOM.  DOM Structure and implements.  XML With DOM.  HTML With DOM.  JavaScript with DOM.  CSS with DOM.  Q&A
  • 3.  Where the Document Object Model came from?  What is Document Object Model ?
  • 4. Where the Document Object Model came from?  "browser wars" of the late 1990s between Netscape Navigator and Microsoft Internet Explorer.  1996 within Netscape Navigator 2.0 “DOM Level 0" or "Legacy DOM”  W3C in late 1998 - > 2000 itro.. DOM Level 1 and 2.  2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers
  • 5. What is Document Object Model ? Document Object Model (DOM), a programming interface specification being developed by the World Wide Web Consortium (W3C), lets a programmer create and modify HTML pages and XML documents as full-fledged program objects. In short..  set of objects/elements  a structure of how these objects/elements can be combined  and an interface to access and modify them
  • 6. Benefits of DOM.  Read the entire document  Represents result as a tree  Lets you search tree  Lets you modify tree  Good for reading data/configuration files  Support in many different languages.
  • 7. DOM Structure and implements  Objects are in a hierarchy  The window is the parent for a given web page.  Document is the child with the objects that are most commonly manipulated [CONTINUED]
  • 8. DOM Tree The usual parent/child relationship between node Like any other tree, you can walk this [CONTINUED]
  • 9. Referencing Objects  By their id or name (this is the easiest way, but you need to make sure a name is unique in the hierarchy)  by their numerical position in the hierarchy, by walking the array that contains them  by their relation to parent, child, or sibling (parentNode, previousSibling, nextSibling, firstChild, lastChild or the childNodes array
  • 10. What is a Node?  Element Node – contains an HTML tag  Text Node – contains text  Text Nodes are contained in Element Nodes [CONTINUED]
  • 11. Nodes Organise the Page html head title text “my page” body p text “This is text on my page” <html> <head> <title>My page</title> </head> <body> <p>This is text on my page</p> </body> </html> [CONTINUED]
  • 12. Adding Some Text To A Page  Create a new Element [document.createElement(“p”)]  Create a Text Node [document.createTextNode(“Some text.”) ]  Attach the New Text Node to the New Element [newNode.appendChild(newText)]  Find an Existing Element [document.getElementById(“thisLocation”)]  Append the New Element to the Existing Element [docElement.appendChild(newNode)] [CONTINUED]
  • 13. Putting the all Steps Together EXAMPLE - 01
  • 14. Remove a Node “To remove a node, we use the element method removeChild (name of node to be removed)” function remText(location) { var docElement; docElement = document.getElementById(location); docElement.removeChild(docElement.lastChild); } [CONTINUED]
  • 15. Best way to the get Element  getElementById() allows you to work with elements by their individual id but often you will want to work with a group of elements  getElementsByTagName() allows you to work with groups of elements. This method returns an array [CONTINUED]
  • 16. Where on the Node Tree?  childNodes  nodeList = node.childNodes  firstChild  reference = node.firstChild  lastChild  nextSibling  parentNode  previousSibling [CONTINUED]
  • 17. Attribute Nodes  We can get at the attributes of an element through attribute nodes  Attribute nodes, like text nodes are always contained in element nodes  We shall look at methods:  getAttribute()  setAttribute() function dispAttribs() { var messg; attribs = new Array; attribs = document.getElementsByTagName("p"); for (i = 0; i < attribs.length; i++) { messg = attribs[i].getAttribute("className"); alert(messg); } } function chngAttribs() { var messg; attribs = new Array; attribs = document.getElementsByTagName("p"); for (i = 0; i < attribs.length; i++) { attribs[i].setAttribute("className","jazz"); } } [CONTINUED]
  • 18. XML With DOM  EXtensible Markup Language (XML) is a meta-language that describes the content of the document (self-describing data).  XML does not specify the tag set or grammar of the language  Media for data interchange  XML only has container tags <blah>...</blah> or <blah/> EXAMPLE-02
  • 19. HTML With DOM  We can track any tag with respect its name and global attribute.  Use to arrange the XML data in UI.  Give Action through the event Handler.  Add and modified the tag with data. [CONTINUED] EXAMPLE-03
  • 20. JavaScript with DOM  JavaScript Objects Reference  Browser Objects Reference  Core DOM Objects Reference  HTML DOM Objects Reference EXAMPLE-04
  • 21. CSS With DOM  Dynamically we can add inner Style sheet.  We can also add css class. EXAMPLE-05
  • 22. All the HTML in the tag is replaced when the innerHTML method is used innerHTML is not part of the DOM – so it may one day disappear – though it is universally recognised by browsers Tags within the innerHTML are not part of the DOM tree so they cannot be manipulated Points to know. [CONTINUED]
  • 23. Points to know.  Understand the nature and structure of the DOM  Add and remove content from the page  Access and change element attributes – including source and class  Insert markup into a page using innerHTML  Change style attribute using Javascript
  • 24. Points to know  DOM makes all components of a web page accessible  HTML elements  their attributes  text  They can be created, modified and removed with JavaScript
  • 25. DOM Standards  W3C www.w3.org/DOM/defines the standards  DOM Level 3 recommendation  www.w3.org/TR/DOM-Level-3-Core/  DOM Level 2 HTML Specification  www.w3.org/TR/DOM-Level-2-HTML/  additional DOM functionality specific to HTML, in particular objects for XHTML elements
  • 26. Email – amit.kumar@above-inc.com With Subject DOM-NTK-Your name.