HTMLElement : Element

HTMLElement is the parent class of all HTML elements.

Browser/User Agent Support

IEMozillaNetscapeOperaSafariNetscapte
3.0+1.0+2.0+7.0+1.0+no

Constructors

ConstructorIEMozillaNetscapeOperaSafariNetscapte
HTMLElement is the parent class of all HTML elements.
3.0+1.0+2.0+7.0+1.0+no
 

Properties

PropertyIEMozillaNetscapeOperaSafariNetscapte
Character for the hotkey that gives focus to the element.
4.0+nonononono
 
Array of all of the elements in the element.
4.0+nonononono
 
Alignment property for the element. Used for display elements. (e.g. "center")
4.0+nonononono
 
Array of attributes for the element.
5.0+1.0+6.0+7.0+1.0+no
 
Gets or sets a time delay to lapse before the element starts "playing".
5.5+nonononono
 
Array of behaviors attached to the element.
5.0+nonononono
 
If true, indicates that the element can have child nodes.
5.0+nonononono
 
If true, indicates that the element can contain HTML tags.
5.5+nonononono
 
Array of the child nodes of the element.
5.0+1.0+6.0+7.0+1.0+no
 
Array of the child nodes of the element.
4.0+nono8.0+1.3+no
 
Name of the CSS class that the element belongs to.
4.0+1.0+6.0+7.0+1.0+no
 
Height of the content of the element (in pixels).
4.0+1.0+7.0+7.0+1.0+no
 
Number of pixels between the offsetLeft property of the element and the start of the content of the element.
4.0+nonononono
 
Number of pixels between the offsetTop property of the element and the top of the content of the element.
4.0+nonononono
 
Width of the content of the element (in pixels).
4.0+1.0+7.0+7.0+1.0+no
 
Indicates whether the content of the element is editable. Possible values are "inherit", "true", or "false".
5.5+nonononono
 
Reference to the Style object specifying the styles applied to the element.
5.0+nonononono
 
Direction of the text in the element. Possible values are "ltr" (left-to-right) or "rtl" (right-to-left).
5.0+1.0+6.0+7.0+1.0+no
 
If true, indicates that the element is disabled.
4.0+1.0+6.0+7.0+1.0+no
 
Reference to the parent Document object for the element.
4.0+nonononono
 
Array of Microsoft CSS filters on the element.
5.5+nonononono
 
Reference to the first child element of the element, if one exists.
5.0+1.0+6.0+7.0+1.0+no
 
If true, indicates that the element is an HTML+TIME media element.
5.5+nonononono
 
If true, the element does not give any visual cues to indicate when it has focus.
5.5+nonononono
 
Unique identifier for the element.
4.0+1.0+6.0+7.0+1.0+no
 
HTML content within the tags of the element.
4.0+1.0+6.0+7.0+1.0+no
  • IE: Buggy on Mac.
Text string enclosed by the tags of the element. Any HTML tags will be interpreted as part of the text string, not as HTML.
4.0+no6.0+7.0+1.0+no
 
If true, indicates that the user can edit the contents of the element.
5.5+nonononono
 
If true, indicates that the element is disabled from user interaction.
5.5+nonononono
 
If true, indicates that a TextRange object can be created using the element.
4.0+nonononono
 
Language code for the content of the element.
4.0+1.0+6.0+7.0+1.0+no
 
4.0+nonononono
 
Reference to the last child element of the element, if it exists.
5.0+1.0+6.0+7.0+1.0+no
 
Local XML name for the element.
no1.0+6.0+7.0+1.0+no
 
The XML Namespace URI for the element.
no1.0+6.0+7.0+1.0+no
 
Reference to the next sibling element of the element.
5.0+1.0+6.0+7.0+1.0+no
 
Name of the element tag.
5.0+1.0+6.0+8.0+1.3+no
 
Node type for the element. See Remarks for full explanation.
5.5+1.0+6.0+8.0+1.3+no
  • IE: IE 5.0 on Windows does not assign nodeType attributes. Fixed in IE 5.5.
Value of the element.
5.0+1.0+6.0+8.0+1.3+no
 
Height of the element (in pixels).
4.0+1.0+6.0+7.0+1.0+no
 
Number of pixels the left edge of the element is offset from the left edge of its parent element.
4.0+1.0+6.0+7.0+1.0+no
 
Reference to the parent object corresponding with the offsetHeight, offsetWidth, offsetLeft, and offsetTop properties.
4.0+1.0+6.0+7.0+1.0+no
 
Number of pixels the top edge of the element is offset from the top edge of its parent element.
4.0+1.0+6.0+7.0+1.0+no
 
Width of the element (in pixels).
4.0+1.0+6.0+7.0+1.0+no
 
Fires when the element becomes active.
4.0+nonononono
 
Fires immediately before the selection is copied to the clipboard.
4.0+nonono1.0+no
 
Fires immediately before the selection is cut to the clipboard.
4.0+nonono1.0+no
 
Fires immediately before the element stops being the active element.
4.0+nonononono
 
Fires immediately before the element receives focus prior to being edited.
4.0+nonononono
 
Fires immediately before the selection is pasted from the clipboard to the element.
4.0+nonono1.0+no
 
Fires when the element loses focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the element is clicked.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the element is right-clicked and the context menu opens.
4.0+nonono1.0+no
 
Fires immediately before the element is selected.
4.0+nonononono
 
Fires when the element is copied to the clipboard.
4.0+nonono1.0+no
 
Fires when the element is cut to the clipboard.
4.0+nonono1.0+no
 
Fires when the element is double-clicked.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the active element becomes inactive.
4.0+nonononono
 
Fires when the element is dragged.
4.0+nonono1.0+no
 
Fires when the element is released from being dragged.
4.0+nonono1.0+no
 
Fires when the element has another object dragged onto it that can be dropped on the element.
4.0+nonono1.0+no
 
Fires when an element has an object dragged out of it that could be dropped onto the element.
4.0+nonono1.0+no
 
Fires when an element has an object dragged over it that could be dropped onto the element.
4.0+nonono1.0+no
 
Fires immediately before an element is dragged.
4.0+nonono1.0+no
 
Fires when an object is dropped onto the element.
4.0+nonono1.0+no
 
Fires when the CSS Filter of an element changes or finishes transitioning.
4.0+nonononono
 
Fires when the element receives focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when a user presses the F1 key to activate help.
4.0+nonononono
 
Fires when a user presses down on a key while the element has focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when a user presses a key or holds down the key while the element has focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when a user releases a key while the element has focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the element loses mouse capture.
4.0+nonononono
 
Fires when a user clicks down on the mouse button while the element has focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the mouse pointer enters the element.
4.0+nonononono
 
Fires when the mouse pointer leaves the element.
4.0+nonononono
 
Fires when the mouse moves while the pointer over the element.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the mouse pointer moves off of the element.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the mouse pointer moves over the element.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the user releases the mouse button while the element has focus.
2.0+1.0+1.0+4.0+1.0+no
 
Fires when the clipboard contents are pasted onto the element.
4.0+nonono1.0+no
 
Fires when one of the properties of the element changes.
4.0+nonononono
 
Fires when the ready state of the element changes.
4.0+nonononono
 
Fires immediately before an element is about to be resized.
4.0+nonono1.0+no
 
Fires when the element is finished being resized.
4.0+nonononono
 
Fires immediately before a user resizes the element.
4.0+nonononono
 
Fires immediately before the element is selected.
4.0+nonono1.0+no
 
HTML mark-up for an element, including start and end tags and any content between the tags.
4.0+nono8.0+1.3+no
 
Plain text for an element, including start and end tags.
4.0+nono8.0+1.3+no
 
Reference to the document that contains the element.
6.0+1.0+6.0+7.0+1.0+no
 
Reference to the direct parent element of the element.
4.0+nonononono
 
Reference to the direct parent node of the element, if it exists.
4.0+1.0+6.0+4.0+1.0+no
 
Reference to the closest parent element to the current element that can create a TextRange that contains the current element.
4.0+nonononono
 
Prefix XML name for the element.
no1.0+no4.0+1.0+no
 
Reference to the previous sibling element of the element, if it exists.
5.0+1.0+6.0+4.0+1.0+no
 
Current readiness state of the element. See Remarks for possible values.
4.0+nonononono
 
Record number for the data set that generated the element.
4.0+nonononono
 
Reference to the Style object specifying the current runtime style(s) of the element.
5.0+nonononono
 
XML scope of the element.
5.0+nonononono
 
Height (in pixels) of the total content area of the element.
4.0+1.0+7.0+7.0+1.0+no
 
Number of pixels between the actual left edge of the element to the displayed left edge of the element.
4.0+1.0+7.0+7.0+1.0+no
 
Number of pixels between the actual top edge of the element to the displayed top edge of the element.
4.0+1.0+7.0+7.0+1.0+no
 
Width (in pixels) of the total content area of the element.
4.0+1.0+7.0+7.0+1.0+no
 
Index of the element in the Document.all[] array.
4.0+nono8.0+nono
 
Reference to the inline CSS style for the element.
4.0+1.0+6.0+7.0+1.0+no
 
If true, indicates that the time container of the element must synchronize playback with the element. Default is false.
5.5+nonononono
 
Indicates the tab order index for the element.
4.0+1.0+6.0+7.0+1.0+no
 
HTML tag name for the element.
4.0+1.0+6.0+8.0+1.3+no
 
URN for the XML Namespace of the element.
5.0+nonononono
 
Gets or sets the type of timeline that corresponds to the element.
5.5+nonononono
 
Value of the title attribute for the element.
4.0+1.0+6.0+7.0+1.0+no
 
System-generated unique identifier for the element.
5.5+nonononono
 

Methods

MethodIEMozillaNetscapeOperaSafariNetscapte
Attaches a behavior to the element as specified in url.
5.0+nonononono
 
Attaches an event listener to an HTMLElement that executes a function when the specified event occurs.
no1.0+no7.0+1.0+no
 
Appends a child element to the end of the childNodes[] array for the element.
5.0+1.0+6.0+7.0+1.0+no
  • IE: Appending an "option" element to a "select" element may crash IE 5.0 on Windows.
Adds a new element to the current element either as a child or parent of the current element.
5.5+nonononono
 
Attaches the specified event handler and function to the element so that every time the event fires, the function is called.
5.0+nono8.0+nono
 
Removes focus from the element.
5.0+1.0+3.0+7.0+1.0+no
 
Removes all attributes and values from the element.
5.0+nonononono
 
Simulates a mouse click on the element. Fires the onclick event.
4.0+1.0+2.0+7.0+1.0+no
 
Clones a node and returns the new node.
5.0+1.0+6.0+7.0+1.0+no
  • IE: On a Mac, IE 5.0 does not clone the event handlers for an element.
Returns a string describing the component at the specified location.
5.0+nonononono
 
Returns true if the HTMLElement contains the specified element.
5.0+nono8.0+nono
 
Detaches the specified function from the event handler so that the function is no longer called when the event fires.
5.0+nono8.0+nono
 
Redirects the specified event instance to be processed by the appropriate handler.
no1.0+6.0+7.0+1.0+no
 
Fires a drag event on the element.
5.5+nonononono
 
Fires an instance of the specified event.
5.5+nonononono
 
Gives focus to the element.
5.0+1.0+6.0+7.0+1.0+no
 
Gets the string of text in the position specified by where.
5.0+nonononono
 
Gets the value of the specified attribute.
4.0+1.0+6.0+7.0+1.0+no
 
Gets the node of the specified attribute.
6.0+1.0+6.0+7.0+1.0+no
 
Returns a TextRectangle that marks the top, bottom, left, and right boundaries (in pixels) of the content of the element.
5.0+nonononono
 
Returns a collection of all of the TextRectangle objects contained by the element.
5.0+nonononono
 
Returns an array of Element nodes with the specified tag name.
5.0+1.0+6.0+8.0+1.0+no
  • IE: Does not work in IE 5.0 on Windows.
Returns the property expression specified by propertyName.
5.0+nonononono
 
Determines if the given attribute exists on this element.
no1.0+6.0+7.0+1.3+no
 
Returns true if the node is an element node with attributes.
no1.0+6.0+7.0+1.3+no
 
Returns true if the node has child nodes.
5.0+1.0+6.0+8.0+1.0+no
 
Inserts the specified Element object adjacent to this element.
5.0+nonononono
 
Inserts the specified string of HTML text adjacent to this element. Parsed as HTML.
4.0+nonononono
 
Inserts the specified string of HTML text adjacent to this element. Not parsed as HTML.
4.0+nonononono
 
Inserts a new child node in front of the reference child node.
5.0+1.0+6.0+8.0+1.0+no
 
Returns true if the specified feature and version are supported.
no1.0+6.0+8.0+1.0+no
 
Merges the attributes from the source element to the current element.
5.0+nonononono
 
Merges text nodes adjacent to the element to create a normalized DOM.
N/A1.0+6.0+8.0+nono
  • IE: May crash IE 6.0.
Stops the mouse from capturing events on the element.
5.0+nonononono
 
Removes an attribute by name
6.0+1.0+6.0+8.0+1.0+no
  • IE: IE does not remove events.
Removes the specified attribute node
6.0+1.0+6.0+8.0+1.0+no
  • IE: Minimal support in IE 6.0 (Windows) and IE 5 (Mac).
Removes the specified attribute node
5.0+nonononono
 
Removes the specified child node from the element and returns the node.
5.0+1.0+6.0+8.0+1.0+no
 
Removes an event listener from an event target.
no1.0+no7.0+1.0+no
 
Removes the specified property expression from the element.
5.0+nonononono
 
Replaces the current text adjacent to the element with the specified text.
5.0+nonononono
 
Removes the specified child node, replaces it with another node, and returns the removed node.
5.0+1.0+6.0+7.0+1.0+no
 
Replaces the current node with the node specified in newNode.
5.0+nonononono
 
Immediately scrolls the element into the viewable portion of the web page.
4.0+1.0+7.0+nonono
 
Sets this element as "active" without giving focus to the element.
5.5+nonononono
 
Adds a new attribute.
4.0+1.0+6.0+7.0+1.0+no
  • IE: IE removes event attributes when you try to set style attributes.
Adds the given attribute node
6.0+1.0+6.0+8.0+1.0+no
  • Safari: Safari will create the attribute, but you will have to use nodeValue to set its value.
Sets mouse capture to the element.
5.0+nonononono
 
Sets the specified expression on the specified property of an element.
5.0+nonononono
 
Swaps the current node with the specified node in the document.
5.0+nonononono
 
Removes the watchpoint from the specified property.
nono4.0+nonono
 
Sets a watch point on a property. When the value of that property changes, the specified handler is automatically invoked.
nono4.0+nonono
 

References

HTMLAnchorElement | HTMLBodyElement | HTMLDocument | HTMLFormElement | HTMLInputElement | HTMLOptionElement | HTMLSelectElement | HTMLTableCaptionElement | HTMLTableCellElement | HTMLTableColElement | HTMLTableElement | HTMLTableRowElement | HTMLTableSectionElement | HTMLTextAreaElement

Availability

HTML DOM Level 2 | W3C

Constructor Detail

HTMLElement HTMLElement()

HTMLElement is the parent class of all HTML elements.

Visibility
internal

Property Detail

String accessKey

Character for the hotkey that gives focus to the element.

Array all - read only

Array of all of the elements in the element.

String align

Alignment property for the element. Used for display elements. (e.g. "center")

Array attributes - read only

Array of attributes for the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

Availability

HTML DOM Level 1

String begin

Gets or sets a time delay to lapse before the element starts "playing".

Array behaviorUrns - read only

Array of behaviors attached to the element.

Boolean canHaveChildren - read only

If true, indicates that the element can have child nodes.

Boolean canHaveHTML - read only

If true, indicates that the element can contain HTML tags.

Array childNodes - read only

Array of the child nodes of the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/children.html

Availability

HTML DOM Level 1

Array children - read only

Array of the child nodes of the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/children.html

String className

Name of the CSS class that the element belongs to.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/taginfo.html

Availability

HTML DOM Level 2 | W3C

Number clientHeight - read only

Height of the content of the element (in pixels).

Number clientLeft - read only

Number of pixels between the offsetLeft property of the element and the start of the content of the element.

Number clientTop - read only

Number of pixels between the offsetTop property of the element and the top of the content of the element.

Number clientWidth - read only

Width of the content of the element (in pixels).

String contentEditable

Indicates whether the content of the element is editable. Possible values are "inherit", "true", or "false".

Object currentStyle - read only

Reference to the Style object specifying the styles applied to the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

String dir

Direction of the text in the element. Possible values are "ltr" (left-to-right) or "rtl" (right-to-left).

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/taginfo.html

Availability

HTML DOM Level 2 | W3C

Boolean disabled

If true, indicates that the element is disabled.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/stylesheets.html

Object document

Reference to the parent Document object for the element.

Array filters - read only

Array of Microsoft CSS filters on the element.

Object firstChild - read only

Reference to the first child element of the element, if one exists.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Availability

HTML DOM Level 1

Boolean hasMedia

If true, indicates that the element is an HTML+TIME media element.

Boolean hideFocus

If true, the element does not give any visual cues to indicate when it has focus.

String id

Unique identifier for the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/taginfo.html

Availability

HTML DOM Level 2 | W3C

String innerHTML

HTML content within the tags of the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/innerhtml.html

String innerText

Text string enclosed by the tags of the element. Any HTML tags will be interpreted as part of the text string, not as HTML.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/innerhtml.html

Boolean isContentEditable - read only

If true, indicates that the user can edit the contents of the element.

Boolean isDisabled - read only

If true, indicates that the element is disabled from user interaction.

Boolean isTextEdit - read only

If true, indicates that a TextRange object can be created using the element.

String lang

Language code for the content of the element.

Availability

HTML DOM Level 2 | W3C

String language

Object lastChild

Reference to the last child element of the element, if it exists.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Availability

HTML DOM Level 1

String localName - read only

Local XML name for the element.

String namespaceURI - read only

The XML Namespace URI for the element.

Object nextSibling - read only

Reference to the next sibling element of the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Availability

HTML DOM Level 1

String nodeName - read only

Name of the element tag.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Remarks
Returns an uppercase tag name.
Availability

HTML DOM Level 1

Number nodeType - read only

Node type for the element. See Remarks for full explanation.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Availability

HTML DOM Level 1

String nodeValue

Value of the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Availability

HTML DOM Level 1

Number offsetHeight - read only

Height of the element (in pixels).

See Also

offsetLeft | offsetParent | offsetTop | offsetWidth

Number offsetLeft - read only

Number of pixels the left edge of the element is offset from the left edge of its parent element.

See Also

offsetHeight | offsetParent | offsetTop | offsetWidth

Object offsetParent - read only

Reference to the parent object corresponding with the offsetHeight, offsetWidth, offsetLeft, and offsetTop properties.

See Also

offsetHeight | offsetLeft | offsetTop | offsetWidth

Number offsetTop - read only

Number of pixels the top edge of the element is offset from the top edge of its parent element.

Number offsetWidth - read only

Width of the element (in pixels).

Function onactivate - read only

Fires when the element becomes active.

Function onbeforecopy - read only

Fires immediately before the selection is copied to the clipboard.

Function onbeforecut - read only

Fires immediately before the selection is cut to the clipboard.

Function onbeforedeactivate - read only

Fires immediately before the element stops being the active element.

Function onbeforeeditfocus - read only

Fires immediately before the element receives focus prior to being edited.

Function onbeforepaste - read only

Fires immediately before the selection is pasted from the clipboard to the element.

Function onblur - read only

Fires when the element loses focus.

Function onclick - read only

Fires when the element is clicked.

Function oncontextmenu - read only

Fires when the element is right-clicked and the context menu opens.

Function oncontrolselect - read only

Fires immediately before the element is selected.

Function oncopy - read only

Fires when the element is copied to the clipboard.

Function oncut - read only

Fires when the element is cut to the clipboard.

Function ondblclick - read only

Fires when the element is double-clicked.

Function ondeactivate - read only

Fires when the active element becomes inactive.

Function ondrag - read only

Fires when the element is dragged.

Function ondragend - read only

Fires when the element is released from being dragged.

Function ondragenter - read only

Fires when the element has another object dragged onto it that can be dropped on the element.

Function ondragleave - read only

Fires when an element has an object dragged out of it that could be dropped onto the element.

Function ondragover - read only

Fires when an element has an object dragged over it that could be dropped onto the element.

Function ondragstart - read only

Fires immediately before an element is dragged.

Function ondrop - read only

Fires when an object is dropped onto the element.

Function onfilterchange - read only

Fires when the CSS Filter of an element changes or finishes transitioning.

Function onfocus - read only

Fires when the element receives focus.

Function onhelp - read only

Fires when a user presses the F1 key to activate help.

Function onkeydown - read only

Fires when a user presses down on a key while the element has focus.

Function onkeypress - read only

Fires when a user presses a key or holds down the key while the element has focus.

Function onkeyup - read only

Fires when a user releases a key while the element has focus.

Function onlosecapture - read only

Fires when the element loses mouse capture.

Function onmousedown - read only

Fires when a user clicks down on the mouse button while the element has focus.

Function onmouseenter - read only

Fires when the mouse pointer enters the element.

Remarks
Differs from onmouseover in that onmouseenter does not bubble and is not cancelable.

Function onmouseleave - read only

Fires when the mouse pointer leaves the element.

Remarks
Differs from onmouseout in that onmouseleave does not bubble and is not cancelable.

Function onmousemove - read only

Fires when the mouse moves while the pointer over the element.

Function onmouseout - read only

Fires when the mouse pointer moves off of the element.

Function onmouseover - read only

Fires when the mouse pointer moves over the element.

Function onmouseup - read only

Fires when the user releases the mouse button while the element has focus.

Function onpaste - read only

Fires when the clipboard contents are pasted onto the element.

Function onpropertychange - read only

Fires when one of the properties of the element changes.

Function onreadystatechange - read only

Fires when the ready state of the element changes.

Function onresize - read only

Fires immediately before an element is about to be resized.

Function onresizeend - read only

Fires when the element is finished being resized.

Function onresizestart - read only

Fires immediately before a user resizes the element.

Function onselectstart - read only

Fires immediately before the element is selected.

String outerHTML

HTML mark-up for an element, including start and end tags and any content between the tags.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/innerhtml.html

See Also

innerHTML | outerText

String outerText

Plain text for an element, including start and end tags.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/innerhtml.html

See Also

outerHTML | innerText

Object ownerDocument - read only

Reference to the document that contains the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/document.html

Availability

HTML DOM Level 1

Object parentElement - read only

Reference to the direct parent element of the element.

Object parentNode - read only

Reference to the direct parent node of the element, if it exists.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

See Also

parentElement

Availability

HTML DOM Level 1

Object parentTextEdit - read only

Reference to the closest parent element to the current element that can create a TextRange that contains the current element.

String prefix - read only

Prefix XML name for the element.

Object previousSibling - read only

Reference to the previous sibling element of the element, if it exists.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Availability

HTML DOM Level 1

String readyState - read only

Current readiness state of the element. See Remarks for possible values.

Remarks
Valid values are 0 = uninitialized, 1 = open, 2 = sent, 3 = receiving, 4 = loaded.

Number recordNumber - read only

Record number for the data set that generated the element.

Number runtimeStyle - read only

Reference to the Style object specifying the current runtime style(s) of the element.

String scopeName - read only

XML scope of the element.

Number scrollHeight - read only

Height (in pixels) of the total content area of the element.

Number scrollLeft

Number of pixels between the actual left edge of the element to the displayed left edge of the element.

Number scrollTop

Number of pixels between the actual top edge of the element to the displayed top edge of the element.

Number scrollWidth - read only

Width (in pixels) of the total content area of the element.

Number sourceIndex - read only

Index of the element in the Document.all[] array.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

HTMLStyleObject style - read only

Reference to the inline CSS style for the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

Availability

HTML DOM Level 2

Boolean syncMaster - read only

If true, indicates that the time container of the element must synchronize playback with the element. Default is false.

Number tabIndex

Indicates the tab order index for the element.

String tagName

HTML tag name for the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Availability

HTML DOM Level 1

String tagURN

URN for the XML Namespace of the element.

String timeContainer

Gets or sets the type of timeline that corresponds to the element.

String title

Value of the title attribute for the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/innerhtml.html

Availability

HTML DOM Level 2 | W3C

String uniqueID - read only

System-generated unique identifier for the element.

Method Detail

addBehavior(String url) : HTMLElement

Attaches a behavior to the element as specified in url.

StringurlReference to the behavior to attach.

addEventListener(String whichEvent, Object handler, Boolean direction) : HTMLElement

Attaches an event listener to an HTMLElement that executes a function when the specified event occurs.

StringwhichEventEvent to trigger the specified function.
ObjecthandlerFunction to execute when the specified event occurs.
BooleandirectionSpecify true to fire the event during the capture phase. Specify false to fire the event during the bubbling phase.

For examples, see the quirksmode test page:

http://www.quirksmode.org/js/events/registration.html

Availability

HTML DOM Level 2

appendChild(Node newChild) : HTMLElement

Appends a child element to the end of the childNodes[] array for the element.

NodenewChildNode to add to the current element as a child.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

Availability

HTML DOM Level 1

applyElement(String newElement, [String where]) : HTMLElement

Adds a new element to the current element either as a child or parent of the current element.

StringnewElementTag name of the element to add.
StringwhereSpecifies where to add the new element (i.e. either as a parent or child of the current element). Specify a value of "outside" (or omit) to add the new element as a parent to the current element. Otherwise the new element becomes the first child of the current element and any existing children of the current element then become direct children of the new element. (optional)

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

attachEvent(String whichHandler, String theFunction) : void

Attaches the specified event handler and function to the element so that every time the event fires, the function is called.

StringwhichHandlerEvent handler to attach.
StringtheFunctionFunction to attach to the event handler.

For examples, see the quirksmode test page:

http://www.quirksmode.org/js/events/registration.html

blur() : void

Removes focus from the element.

Availability

HTML DOM Level 1

clearAttributes() : void

Removes all attributes and values from the element.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes3.html

click() : void

Simulates a mouse click on the element. Fires the onclick event.

cloneNode(Boolean cloneChildren) : Node

Clones a node and returns the new node.

BooleancloneChildrenIf true, specifies that any child nodes of the node should also be cloned.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

Availability

HTML DOM Level 1

componentFromPoint(Boolean x, Boolean y) : String

Returns a string describing the component at the specified location.

BooleanxX-coordinate (in pixels).
BooleanyY-coordinate (in pixels).

contains(Boolean element) : Boolean

Returns true if the HTMLElement contains the specified element.

BooleanelementElement to check for.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/basics.html

detachEvent(Object whichHandler, Object theFunction) : void

Detaches the specified function from the event handler so that the function is no longer called when the event fires.

ObjectwhichHandlerEvent handler to detach.
ObjecttheFunctionFunction to detach.

For examples, see the quirksmode test page:

http://www.quirksmode.org/js/events/registration.html

dispatchEvent(Boolean event) : void

Redirects the specified event instance to be processed by the appropriate handler.

BooleaneventEvent to redirect.

Availability

HTML DOM Level 2

dragDrop() : void

Fires a drag event on the element.

fireEvent(Boolean handler, [Boolean event]) : void

Fires an instance of the specified event.

BooleanhandlerEvent handler for the event.
BooleaneventEvent to fire. (optional)

focus() : void

Gives focus to the element.

Availability

HTML DOM Level 2

getAdjacentText(String where) : String

Gets the string of text in the position specified by where.

StringwhereSpecifies where to get the adjacent text from, relative to the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.

getAttribute(String attributeName) : String

Gets the value of the specified attribute.

StringattributeNameName of the attribute.

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes2.html

getAttributeNode(String attributeName) : Node

Gets the node of the specified attribute.

StringattributeNameName of the attribute.

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes2.html

Availability

HTML DOM Level 1

getBoundingClientRect() : Object

Returns a TextRectangle that marks the top, bottom, left, and right boundaries (in pixels) of the content of the element.

getClientRects() : Object

Returns a collection of all of the TextRectangle objects contained by the element.

getElementsByTagName(String tagname) : static Array

Returns an array of Element nodes with the specified tag name.

StringtagnameTag name of the elements to return. Specify "*" to return all tags. (one-or-more)

Using getElementsByTagName

// Assume there is only one  in the document
                    var body = document.getElementsByTagName("body").item(0);
                    var paragraphs = body.getElementsByTagName("p");

For additional examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/basics.html

Remarks

This method returns a list of elements in the document that have the specified tagName. The returned NodeList is sorted in the order the elements were found during a depth-first preorder traversal through the node tree.

See Also

Document.getElementById | Element.getElementsByTagName | HTMLDocument.getElementsByName

Availability

HTML DOM Level 1

getExpression(String propertyName) : String

Returns the property expression specified by propertyName.

StringpropertyNameName of the property/attribute.

hasAttribute(String name) : Boolean

Determines if the given attribute exists on this element.

StringnameName of the attribute to check.

Using hasAttribute

if (!element.hasAttribute("id")) {
                    element.setAttribute("id", "newvalue");
                    }

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes3.html

Remarks
Use this method to verify that an attribute exists on an Element before retrieving that attribute.
See Also

Attr.specified | HTMLElement.getAttribute | HTMLElement.setAttribute

Availability

HTML DOM Level 2

hasAttributes() : Boolean

Returns true if the node is an element node with attributes.

Using hasAttributes

var obj = document.Document.getElementById('EmailAddress');
                    if (obj.hasAttributes()) {
                    window.alert("The node " + obj.Node.nodeName + " has attributes");
                    }

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes3.html

Remarks
Returns true if this node is an Element and has any attributes. Returns false if there are none. Equivilant to checking node.attributes.NamedNodeMap.length > 0.
See Also

HTMLElement.getAttribute | HTMLElement.hasAttribute | Node.attributes

Availability

HTML DOM Level 2

hasChildNodes() : Boolean

Returns true if the node has child nodes.

Using hasChildNodes

var obj = document.Document.getElementById('EmailAddress');
                    if (obj.hasChildNodes()) {
                    window.alert("The node " + obj.Node.nodeName + " has children");
                    }
Remarks
Returns true if this node has any child nodes. Returns false if there are none. Equivilant to checking node.childNodes.NodeList.length > 0.
See Also

Node.childNodes

Availability

HTML DOM Level 1

insertAdjacentElement(String where, Element element) : void

Inserts the specified Element object adjacent to this element.

StringwhereSpecifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
ElementelementElement to insert.

See Also

HTMLElement.insertAdjacentHTML | HTMLElement.insertText

insertAdjacentHTML(String where, String text) : void

Inserts the specified string of HTML text adjacent to this element. Parsed as HTML.

StringwhereSpecifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
StringtextHTML text to insert.

See Also

HTMLElement.insertAdjacentElement | HTMLElement.insertAdjacentText

insertAdjacentText(String where, String text) : void

Inserts the specified string of HTML text adjacent to this element. Not parsed as HTML.

StringwhereSpecifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
StringtextText string to insert.

See Also

HTMLElement.insertAdjacentElement | HTMLElement.insertAdjacentHTML | HTMLElement.replaceAdjacentText

insertBefore(Node newChild, Node refChild) : void

Inserts a new child node in front of the reference child node.

NodenewChildNew child node to insert.
NoderefChildReference child node.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

See Also

HTMLElement.replaceNode

Availability

HTML DOM Level 1

isSupported(String feature, [String version]) : Boolean

Returns true if the specified feature and version are supported.

StringfeatureName of the feature.
StringversionVersion of the feature. (optional)

Remarks
Tests whether a node supports the specified feature. Similar to the DOMImplementation.hasFeature method and takes the same feature names. If version is null, returns true if any version of the feature is supported.
See Also

DOMImplementation.hasFeature

Availability

HTML DOM Level 2

mergeAttributes(Object source, [Boolean preserve]) : void

Merges the attributes from the source element to the current element.

ObjectsourceSource that supplies the attributes.
BooleanpreserveIf true, specifies that the id of the current element should be preserved. (optional)

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

normalize() : void

Merges text nodes adjacent to the element to create a normalized DOM.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/splittext.html

Remarks
Normalizes any Text nodes contained under this node and all of its children. Merges any adjacent Text nodes into one object, so that the nodes reflect how they would be structured if this XML document were freshly loaded.

Normalize() is useful for manipulating the text content of nodes for editing. Instead of worrying about altering existing Text nodes, you can simply add new nodes and perform the normalize when you finish your updates.

Availability

HTML DOM Level 1

releaseCapture() : void

Stops the mouse from capturing events on the element.

removeAttribute(String name) : void

Removes an attribute by name

StringnameName of the attribute to remove.

Using removeAttribute

if (element.hasAttribute("id")) {
                    element.removeAttribute("id");
                    }

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes2.html

Remarks
Removes the specified attribute from the element. If the attribute has a defined default value, it will be set to that default value.
Throws
Raises a NO_MODIFICATION_ALLOWED_ERR error if the node is read-only.
See Also

HTMLElement.getAttribute | HTMLElement.setAttribute | Node.attributes

Availability

HTML DOM Level 1

removeAttributeNode(Attr oldAttr) : static Attr

Removes the specified attribute node

AttroldAttrNode to remove from the attribute.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes2.html

Remarks
Removes an attribute from an element. If the attribute has a defined default value, the new attribute node value will immediately be set to that.
Throws
Raises a NO_MODIFICATION_ALLOWED_ERR error if the node is read-only. Raises a NOT_FOUND_ERR error if oldAttr object is not an attribute of this element.
See Also

Attr | Element.removeAttribute

Availability

HTML DOM Level 1

removeBehavior(String id) : static Boolean

Removes the specified attribute node

Stringidid of the behavior to remove.

Remarks
Removes the behavior specified by id from the element.
See Also

HTMLElement.addBehavior

removeChild(Node oldChild) : static Node

Removes the specified child node from the element and returns the node.

NodeoldChildChild node to remove.

Using removeChild

var obj = document.Document.getElementById('EmailAddress');
                    try {
                    var oldChild = obj.removeChild(obj.Node.firstChild);
                    } catch DOMException {
                    // Error handling
                    };

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

Remarks
Removes and returns the specified child node from the list of this node's children.
Throws
Raises a NO_MODIFICATION_ALLOWED_ERR if the node is read-only.
Raises a NOT_FOUND_ERR if the supplied node is not a child of this one.
See Also

Node.appendChild | Node.insertBefore | Node.replaceChild

Availability

HTML DOM Level 1

removeEventListener(String type, EventListener listener, Boolean useCapture) : void

Removes an event listener from an event target.

StringtypeType of event.
EventListenerlistenerEvent listener to be removed.
BooleanuseCaptureSpecify "true" to remove a capturing event listener. Specify "false" to remove all other types of event listeners.

For examples, see the quirksmode test page:

http://www.quirksmode.org/js/events/registration.html

Availability

HTML DOM Level 2

removeExpression(String propertyName) : void

Removes the specified property expression from the element.

StringpropertyNameName of the property expression to remove.

replaceAdjacentText(String where, String text) : void

Replaces the current text adjacent to the element with the specified text.

StringwhereSpecifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
StringtextText to replace the current text with.

See Also

HTMLElement.insertAdjacentText

replaceChild(Node newChild, Node oldChild) : static Node

Removes the specified child node, replaces it with another node, and returns the removed node.

NodenewChildNode to replace the oldChild node with.
NodeoldChildNode to be replaced.

Using replaceChild

var obj = document.Document.getElementById('EmailAddress');
                    var newElement = document.Document.createElement('label');
                    try {
                    var oldChild = obj.replaceChild(newElement, obj.Node.lastChild);
                    } catch DOMException {
                    // Error handling
                    };

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

Remarks
This method simplifies the process of calling removeChild and then insertBefore, so that you do not have to worry if this node is the first or last child.

The new child node is removed if it already exists somewhere else in the DOM tree. If the new child is a DocumentFragment node, the oldChild node is replaced by all of the nodes within the DocumentFragment, in the same order.

Throws
Raises a HIERARCHY_REQUEST_ERR error if either the node being inserted is one of this node's ancestors, or if the current node does not allow this type of node as a child.
Raises a WRONG_DOCUMENT_ERR error if the newChild node was not created within the current document.
Raises a NO_MODIFICATION_ALLOWED_ERR if this node is read-only or if the parent of the new node is read-only.
Raises a NOT_FOUND_ERR if the supplied oldChild node is not a child of this one.
See Also

HTMLElement.appendChild | HTMLElement.insertBefore | HTMLElement.removeChild

Availability

HTML DOM Level 1

replaceNode(Node newNode) : void

Replaces the current node with the node specified in newNode.

NodenewNodeNode to replace the current node with.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

See Also

HTMLElement.insertBefore

scrollIntoView([Boolean alignToTop]) : void

Immediately scrolls the element into the viewable portion of the web page.

BooleanalignToTopIf true, specifies that the top of the element will be scrolled to align with the top of the window. Default is true. (optional)

Remarks
Use the scrollIntoView method to visually direct users to a specific part of a web page, without forcing the users to scroll the page themselves. (e.g. Scrolling down to the "total" of a long shopping cart page.)

setActive() : void

Sets this element as "active" without giving focus to the element.

setAttribute(String name, String value) : void

Adds a new attribute.

StringnameName of the attribute to set.
StringvalueString value of the attribute to set.

Using setAttribute

var node = document.getElementById('address-list');
                    document.setAttribute('ref', 'urn:root');
                    document.setAttribute('datasources', 'http://mozref.com/reference/objects.rdf');

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes2.html

Remarks
Sets either a new attribute value or updates an existing attribute value. This method can only set values as text strings, not HTML. Entities will not be parsed. To assign values containing entities to an attribute, use setAttributeNode.
Throws
Raises an INVALID_CHARACTER_ERR error if the supplied name contains an invalid character.
Raises a NO_MODIFICATION_ALLOWED_ERR error if the node is read-only.
See Also

HTMLElement.getAttribute | HTMLElement.removeAttribute | HTMLElement.setAttributeNode

Availability

HTML DOM Level 1

setAttributeNode(Attr newAttr) : static Attr

Adds the given attribute node

AttrnewAttrAttr node of the attribute to set.

Using setAttributeNode

var attr = node1.getAttributeNode("class");
                    node1.removeAttribute("class");
                    node2.setAttributeNode(attr);

For more examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes3.html

Remarks

This method adds the specified Attr object as an attribute to the current element. You may specifiy actual DOM nodes instead of specifying separate arguments for the attribute name and value.

If the element already has the attribute, setAttribute will replace the node and return the old attribute node. Returns null, otherwise.

Throws
Raises a WRONG_DOCUMENT_ERR error if the supplied newAttr was created from a different document.
Raises a NO_MODIFICATION_ALLOWED_ERR error if the node is read-only.
Raises an INUSE_ATTRIBUTE_ERR error if the supplied newAttr is already bound to another Element object.
See Also

Attr | HTMLElement.setAttribute

Availability

HTML DOM Level 1

setCapture([Boolean containerCapture]) : void

Sets mouse capture to the element.

BooleancontainerCaptureIf true, specifies that events that originate in the container will be captured by the container. (optional)

Remarks
Once set, routes all mouse events to this element.

setExpression(String property, String expression, [String language]) : void

Sets the specified expression on the specified property of an element.

StringpropertyName of the property to add the expression to.
StringexpressionExpression to set.
StringlanguageScripting language to use. Default is JScript. Other valid values are JavaScript and VBScript. (optional)

See Also

HTMLElement.removeExpression

swapNode(Node node) : Node

Swaps the current node with the specified node in the document.

NodenodeNode to swap this node with.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/movingnodes.html

unwatch(String property) : void

Removes the watchpoint from the specified property.

StringpropertyProperty to remove the watch point from.

watch(String property, String handler) : void

Sets a watch point on a property. When the value of that property changes, the specified handler is automatically invoked.

StringpropertyProperty to set the watch point on.
StringhandlerHandler to invoke when the specified property changes.