Sams Teach Yourself JavaScript in 24 Hours Free Open Book

Sams Teach Yourself JavaScript in 24 Hours

Previous Page
Next Page

DOM Level 1

The level 1 DOM is the first cross-browser DOM standardized by the W3C. Its objects are stored under the document object of the level 0 DOM.

Basic Node Properties

Each object has certain common properties:

  • nodeName is the name of the node (not the ID). The name is the tag name for HTML tag nodes, #document for the document node, and #text for text nodes.

  • nodeType is a number describing the node's type: 1 for HTML tags, 3 for text nodes, and 9 for the document.

  • nodeValue is the text contained within a text node.

  • innerHTML is the HTML contents of a container node.

  • id is the value of the ID attribute for the node.

  • classname is the value of the class attribute for the node.

Relationship Properties

The following properties describe an object's relationship with others in the hierarchy:

  • firstChild is the first child node for the current node.

  • lastChild is the last child object for the current node.

  • childNodes is an array of all the child nodes under a node.

  • previousSibling is the sibling before the current node.

  • nextSibling is the sibling after the current node.

  • parentNode is the object that contains the current node.

Offset Properties

Although not part of the W3C DOM, both Netscape and Internet Explorer support the following properties that provide information about a node's position:

  • offsetLeft is the distance from the left side of the browser window or containing object to the left edge of the node object.

  • offsetTop is the distance from the top of the browser window or containing object to the top of the node object.

  • offsetHeight is the height of the node object.

  • offsetWidth is the width of the node object.

Style Properties

The style child object under each DOM object includes its style sheet properties. These are based on attributes of a style attribute, <style> tag, or external style sheet. See Hour 12, "Working with Style Sheets," for details on these properties.

Node Methods

The following methods are available for all DOM nodes:

  • appendChild(node) adds a new child node to the node after all its existing children.

  • insertBefore(node,oldnode) inserts a new node before the specified existing child node.

  • replaceChild(node,oldnode) replaces the specified old child node with a new node.

  • removeChild(node) removes an existing child node.

  • hasChildNodes() returns a Boolean value of true if the node has one or more children, or false if it has none.

  • cloneNode() returns a copy of the current node.

  • getAttribute(attribute_name) gets the value of the attribute you specify and stores it in a variable.

  • setAttribute(attribute_name, value) sets the value of an attribute.

  • removeAttribute(attribute_name) removes the attribute you specify.

  • hasAttributes() simply returns true if the node has attributes, and false if it has none.

Document Object Methods and Properties

The following are methods and properties of the document object:

  • document.getElementById(ID) returns the element with the specified ID attribute.

  • document.getElementsByTagName(tag) returns an array of the elements with the specified tag name. You can use the asterisk (*) as a wildcard to return an array containing all of the nodes in the document.

  • document.createElement(tag) creates a new element with the specified tag name.

  • document.createTextNode(text) creates a new text node containing the specified text.

  • document.documentElement is an object that represents the document itself, and can be used to find information about the document.

Previous Page
Next Page
Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y]


     Main Menu
Sams Teach Yourself JavaScript in 24 Hours
Table of Contents
Copyright
About the Author
Acknowledgments
Part I: Introducing the Concept of Web scripting and the JavaScript Language
Part II: Learning JavaScript Basics
Part III: Learning More About the DOM
Part IV: Working with Advanced JavaScript Features
Part V: Building Multimedia Applications with JavaScript
Part VI: Creating Complex Scripts
Part VII: Appendixes
Appendix A. Other JavaScript Resources
Appendix B. Tools for JavaScript Developers
Appendix C. Glossary
Glossary
Appendix D. JavaScript Quick Reference
Appendix E. DOM Quick Reference
DOM Level 0
DOM Level 1
Index


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele