spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column43


The Document Object Model (DOM), Part 4 (3)

Biz Resources
ERP Software
Computer Hardware
Data Backup Services
Developer News
MicrosoftÂ’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear
Red Hat Heads For The JON 2.0

Manipulating Documents using Methods

The Document Object Model provides a set of methods that you can use to create, delete, insert, exchange, and replace nodes with. When using the DOM's methods, you need to think in the terms we have introduced in the last three columns, i.e. document trees and document nodes. The table below shows the DOM's methods. For each method, it shows the syntax by which you may use the method, its argument type, its description, and the value it returns. The terms object and node are completely interchangeable in this table. Any reference to an object may be viewed as a reference to a document tree node, and vice versa. In the following pages we'll cover in depth each of the methods below.

The outcome of cloneNode(deep) and removeNode(deep) depends on the value of deep. When deep is true, the cloneNode method clones a complete subtree rooted at the specified node. When deep is false, just the specified node is duplicated, having no children at all. Similarly, when deep is true, the removeNode method removes a complete subtree rooted at the specified node. When deep is false, just the specified node is removed and all its children become children of their former father's father (former grandfather).

DOM's MethodSyntaxArgument TypeEffectReturned Value
appendChildfatherObj.appendChild(childObj)An [object]Appends an object (childObj) as a child to the specified object (fatherObj).Appended [object]
applyElementchildObj.applyElement(fatherObj)An [object]Appends the object (childObj) as a child to an object (fatherObj).Appended [object]
clearAttributesclearedObj.clearAttributes()NARemoves all attributes (and their values) from the object (clearedObj)Cleared [object]
cloneNodenewObj = originalObj.cloneNode(deep) BooleanCreates a new object (newObj), identical to the original object (originalObj) if deep is true. When deep is false only root will be cloned.An [object]
createElementnewObj = document.createElement("htmlTag")HTML Tag (ex: TR, IMG)Creates a new tag node (newObj).An [object]
createTextNodenewObj = document.createTextNode(string)A String (ex: "this is the document body")Creates a new text node (newObj).An [object]
hasChildNodeshasChildrenFlag = testedObj.hasChildNodes()NAReturns whether the object (testedObj) has children.true for yes, false for no
insertBeforeparentObj.insertBefore(childObj, brotherObj)An [object]Inserts an object (childObj) as a child of the specified object (parentObj) just before the specified child (brotherObj).true if successful, null if not
mergeAttributestargetObj.mergeAttributes(sourceObj)An [object]Copies all attributes from the source object (sourceObj) to the target object (targetObj).Target [object]
removeNodedeletedObj.removeNode(deep)NARemoves the deletedObj's subtree from the document hierarchy when deep is true. Removes just the node when deep is false.Removed [object]
replaceNodeoldObj.replaceNode(newObj)An [object]Replaces an existing node (oldObj) with a new node (newObj).Replaced [object]
swapNodefirstObj.swapNode(secondObj)An [object]Exchanges the positions of two nodes, firstObj and secondObj.Swapped Out [object]

Access FREE IBM Developer Tools:
Webcast:
Asset Reuse Strategies for Success--Innovate Don't Duplicate!
e-Kit:
Rational Build Forge Express
Download:
IBM Data Studio v1.1
e-Kit:
Rational Asset Manager

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Perl Pragma Primer · Implement Drag and Drop in Your Web Apps: Part 2 · How to Create an Ajax Autocomplete Text Field: Part 5
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
SQL Server 2005 Express Edition - Part 22 - Upgrading from Microsoft SQL Server Desktop Engine (MSDE) · Vyatta: Downgrades that Pay Off · NetMotion Brings Cross-Network Support to Wireless VoIP


Created: July 5, 1999
Revised: September 17, 1999

URL: http://www.webreference.com/js/column43/properties.html