Document Object Model (DOM) - Stanford University
Document Object Model (DOM)
Mendel Rosenblum
CS142 Lecture Notes - DOM
Browser JavaScript interface to HTML document
HTML document exposed as a collection of JavaScript objects and methods
The Document Object Model (DOM)
JavaScript can query or modify the HTML document
Accessible via the JavaScript global scope, aliases:
window
this
(When not using 'use strict';)
CS142 Lecture Notes - DOM
DOM hierarchy
Rooted at window.document (html tag) Follows HTML document structure
window.document.head window.document.body Tree nodes (DOM objects) have tons (~250) of properties, most private Objects (representing elements, raw text, etc.) have a common set of properties and methods called a DOM "Node"
CS142 Lecture Notes - DOM
DOM Node properties and methods
Identification nodeName property is element type (uppercase: P, DIV, etc.) or #text
Encode document's hierarchical structure parentNode, nextSibling, previousSibling, firstChild, lastChild.
Provide accessor and mutator methods E.g. getAttribute, setAttribute methods, etc..
CS142 Lecture Notes - DOM
Sample bold display
parentNode
firstChild
nodeName: P nodeType: 1 (Element)
parentNode lastChild
previousSibing
parentNode previousSibing
nodeName: #text
nodeName: B
nodeType: 3 (Text)
nodeType: 1
nodeValue: "Sample " nextSibing
firstChild
lastChild
nodeName: #text nodeType: 3 (Text) nodeValue: " display" nextSibing
parentNode
nodeName: #text
nodeType: 3 (Text)
nodeValue: "bold"
CS142 Lecture Notes - DOM
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ilovecoding javascriptcheatsheet
- document object model dom stanford university
- effective javascript 68 specific ways to harness the
- html css bootstrap javascript and jquery
- geogebra javascript lesson 1
- javascript texas a m university
- exercise 8 1 x accumulate test score data using an array
- ssi system management guide
- using ajax
- final exam wpi
Related searches
- stanford university philosophy department
- stanford university plato
- stanford university encyclopedia of philosophy
- stanford university philosophy encyclopedia
- stanford university philosophy
- html document object model
- stanford university ein number
- stanford university master computer science
- stanford university graduate programs
- stanford university computer science ms
- stanford university phd programs
- stanford university phd in education