Appendix B. DOM Reference

This Appendix assembles all DOM methods and properties that JavaScript exposes. The DOM used is the W3C DOM supported by recent versions of Internet Explorer, Mozilla, Safari/Konqueror, and Opera. Methods and properties that are not supported by either of the two “main” browsers—Internet Explorer and Mozilla brands—are not mentioned.

Square brackets [] denote an array; parentheses () indicate a method.

Generic Methods and Properties

The methods and properties in this section exist for all DOM elements.

Methods

Method

Description

appendChild(node)

Appends a node to the element

appendData(data)

Appends data to a node, not overwriting existing data

blur()

Removes the focus from the element

click()

Simulates a click on the element

cloneNode(deep)

Creates a copy of the node (if deep is true, all subnodes are copied as well)

deleteData(start, length)

Deletes a number of characters

focus()

Gives the focus to the element

getAttribute(attribute)

Returns the value of the given attribute

getAttributeNode(attribute)

Returns the node containing the given attribute

getElementsByTagName(name)

Returns an array of all elements with the given tag name

hasChildNodes()

Whether the element has subnodes or not

insertBefore(node)

Insert a node before the element

insertData(position, data)

Inserts data at a certain position

removeAttribute(attribute)

Removes the given attribute from the element

Get Programming Atlas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.