# HTMLSelectElement : HTMLElement
Return to: HTML DOM Level 2 index

Select element on an HTML form.

## Platform Support

IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | ---
3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

## Constructors

Constructor | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
HTMLSelectElement Constructor() : HTMLSelectElement Select element on an HTML form. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

### HTMLSelectElement() : HTMLSelectElement

Select element on an HTML form.

Returns

HTMLSelectElement |

Visibility
  internal

## Inherited Properties

Property | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
accessKey : String Character for the hotkey that gives focus to the element. | No Details | 4.0+ | no | no | no | no

all : Array Array of all of the elements in the element. | No Details | 4.0+ | no | no | no | no

align : String Alignment property for the element. Used for display elements. (e.g. "center") | No Details | 4.0+ | no | no | no | no

attributes : Array Array of attributes for the element. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

begin : String Gets or sets a time delay to lapse before the element starts "playing". | No Details | 5.5+ | no | no | no | no

behaviorUrns : Array Array of behaviors attached to the element. | No Details | 5.0+ | no | no | no | no

canHaveChildren : Boolean If true, indicates that the element can have child nodes. | No Details | 5.0+ | no | no | no | no

canHaveHTML : Boolean If true, indicates that the element can contain HTML tags. | No Details | 5.5+ | no | no | no | no

childNodes : Array Array of the child nodes of the element. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

children : Array Array of the child nodes of the element. | Show Details | 4.0+ | no | no | 8.0+ | 1.3+

  For examples, see the quirksmode test page:

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

className : String Name of the CSS class that the element belongs to. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 2|W3C

clientHeight : Number Height of the content of the element (in pixels). | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

clientLeft : Number Number of pixels between the offsetLeft property of the element and the start of the content of the element. | No Details | 4.0+ | no | no | no | no

clientTop : Number Number of pixels between the offsetTop property of the element and the top of the content of the element. | No Details | 4.0+ | no | no | no | no

clientWidth : Number Width of the content of the element (in pixels). | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

contentEditable : String Indicates whether the content of the element is editable. Possible values are "inherit", "true", or "false". | No Details | 5.5+ | no | no | no | no

currentStyle : Object Reference to the Style object specifying the styles applied to the element. | Show Details | 5.0+ | no | no | no | no

  For examples, see the quirksmode test page:

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

dir : String Direction of the text in the element. Possible values are "ltr" (left-to-right) or "rtl" (right-to-left). | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 2|W3C

disabled : Boolean If true, indicates that the element is disabled. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

document : Object Reference to the parent Document object for the element. | No Details | 4.0+ | no | no | no | no

filters : Array Array of Microsoft CSS filters on the element. | No Details | 5.5+ | no | no | no | no

firstChild : Object Reference to the first child element of the element, if one exists. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

hasMedia : Boolean If true, indicates that the element is an HTML+TIME media element. | No Details | 5.5+ | no | no | no | no

hideFocus : Boolean If true, the element does not give any visual cues to indicate when it has focus. | No Details | 5.5+ | no | no | no | no

id : String Unique identifier for the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 2|W3C

innerHTML : String HTML content within the tags of the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

- IE: Buggy on Mac.

  For examples, see the quirksmode test page:

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

innerText : String Text string enclosed by the tags of the element. Any HTML tags will be interpreted as part of the text string, not as HTML. | Show Details | 4.0+ | no | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

isContentEditable : Boolean If true, indicates that the user can edit the contents of the element. | No Details | 5.5+ | no | no | no | no

isDisabled : Boolean If true, indicates that the element is disabled from user interaction. | No Details | 5.5+ | no | no | no | no

isTextEdit : Boolean If true, indicates that a TextRange object can be created using the element. | No Details | 4.0+ | no | no | no | no

lang : String Language code for the content of the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 2|W3C

language : String | No Details | 4.0+ | no | no | no | no

lastChild : Object Reference to the last child element of the element, if it exists. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

localName : String Local XML name for the element. | No Details | no | 1.0+ | 6.0+ | 7.0+ | 1.0+

namespaceURI : String The XML Namespace URI for the element. | No Details | no | 1.0+ | 6.0+ | 7.0+ | 1.0+

nextSibling : Object Reference to the next sibling element of the element. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

nodeName : String Name of the element tag. | Show Details | 5.0+ | 1.0+ | 6.0+ | 8.0+ | 1.3+

  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

nodeType : Number Node type for the element. See Remarks for full explanation. | Show Details | 5.5+ | 1.0+ | 6.0+ | 8.0+ | 1.3+

- IE: IE 5.0 on Windows does not assign nodeType attributes. Fixed in IE 5.5.

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

nodeValue : String Value of the element. | Show Details | 5.0+ | 1.0+ | 6.0+ | 8.0+ | 1.3+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

offsetHeight : Number Height of the element (in pixels). | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

See Also

  offsetLeft|offsetParent|offsetTop|offsetWidth

offsetLeft : Number Number of pixels the left edge of the element is offset from the left edge of its parent element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

See Also

  offsetHeight|offsetParent|offsetTop|offsetWidth

offsetParent : Object Reference to the parent object corresponding with the offsetHeight, offsetWidth, offsetLeft, and offsetTop properties. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

See Also

  offsetHeight|offsetLeft|offsetTop|offsetWidth

offsetTop : Number Number of pixels the top edge of the element is offset from the top edge of its parent element. | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

offsetWidth : Number Width of the element (in pixels). | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

onactivate : Function Fires when the element becomes active. | No Details | 4.0+ | no | no | no | no

onbeforecopy : Function Fires immediately before the selection is copied to the clipboard. | No Details | 4.0+ | no | no | no | 1.0+

onbeforecut : Function Fires immediately before the selection is cut to the clipboard. | No Details | 4.0+ | no | no | no | 1.0+

onbeforedeactivate : Function Fires immediately before the element stops being the active element. | No Details | 4.0+ | no | no | no | no

onbeforeeditfocus : Function Fires immediately before the element receives focus prior to being edited. | No Details | 4.0+ | no | no | no | no

onbeforepaste : Function Fires immediately before the selection is pasted from the clipboard to the element. | No Details | 4.0+ | no | no | no | 1.0+

onblur : Function Fires when the element loses focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onclick : Function Fires when the element is clicked. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

oncontextmenu : Function Fires when the element is right-clicked and the context menu opens. | No Details | 4.0+ | no | no | no | 1.0+

oncontrolselect : Function Fires immediately before the element is selected. | No Details | 4.0+ | no | no | no | no

oncopy : Function Fires when the element is copied to the clipboard. | No Details | 4.0+ | no | no | no | 1.0+

oncut : Function Fires when the element is cut to the clipboard. | No Details | 4.0+ | no | no | no | 1.0+

ondblclick : Function Fires when the element is double-clicked. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

ondeactivate : Function Fires when the active element becomes inactive. | No Details | 4.0+ | no | no | no | no

ondrag : Function Fires when the element is dragged. | No Details | 4.0+ | no | no | no | 1.0+

ondragend : Function Fires when the element is released from being dragged. | No Details | 4.0+ | no | no | no | 1.0+

ondragenter : Function Fires when the element has another object dragged onto it that can be dropped on the element. | No Details | 4.0+ | no | no | no | 1.0+

ondragleave : Function Fires when an element has an object dragged out of it that could be dropped onto the element. | No Details | 4.0+ | no | no | no | 1.0+

ondragover : Function Fires when an element has an object dragged over it that could be dropped onto the element. | No Details | 4.0+ | no | no | no | 1.0+

ondragstart : Function Fires immediately before an element is dragged. | No Details | 4.0+ | no | no | no | 1.0+

ondrop : Function Fires when an object is dropped onto the element. | No Details | 4.0+ | no | no | no | 1.0+

onfilterchange : Function Fires when the CSS Filter of an element changes or finishes transitioning. | No Details | 4.0+ | no | no | no | no

onfocus : Function Fires when the element receives focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onhelp : Function Fires when a user presses the F1 key to activate help. | No Details | 4.0+ | no | no | no | no

onkeydown : Function Fires when a user presses down on a key while the element has focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onkeypress : Function Fires when a user presses a key or holds down the key while the element has focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onkeyup : Function Fires when a user releases a key while the element has focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onlosecapture : Function Fires when the element loses mouse capture. | No Details | 4.0+ | no | no | no | no

onmousedown : Function Fires when a user clicks down on the mouse button while the element has focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onmouseenter : Function Fires when the mouse pointer enters the element. | Show Details | 4.0+ | no | no | no | no

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

onmouseleave : Function Fires when the mouse pointer leaves the element. | Show Details | 4.0+ | no | no | no | no

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

onmousemove : Function Fires when the mouse moves while the pointer over the element. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onmouseout : Function Fires when the mouse pointer moves off of the element. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onmouseover : Function Fires when the mouse pointer moves over the element. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onmouseup : Function Fires when the user releases the mouse button while the element has focus. | No Details | 2.0+ | 1.0+ | 1.0+ | 4.0+ | 1.0+

onpaste : Function Fires when the clipboard contents are pasted onto the element. | No Details | 4.0+ | no | no | no | 1.0+

onpropertychange : Function Fires when one of the properties of the element changes. | No Details | 4.0+ | no | no | no | no

onreadystatechange : Function Fires when the ready state of the element changes. | No Details | 4.0+ | no | no | no | no

onresize : Function Fires immediately before an element is about to be resized. | No Details | 4.0+ | no | no | no | 1.0+

onresizeend : Function Fires when the element is finished being resized. | No Details | 4.0+ | no | no | no | no

onresizestart : Function Fires immediately before a user resizes the element. | No Details | 4.0+ | no | no | no | no

onselectstart : Function Fires immediately before the element is selected. | No Details | 4.0+ | no | no | no | 1.0+

outerHTML : String HTML mark-up for an element, including start and end tags and any content between the tags. | Show Details | 4.0+ | no | no | 8.0+ | 1.3+

  For examples, see the quirksmode test page:

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

See Also

  innerHTML|outerText

outerText : String Plain text for an element, including start and end tags. | Show Details | 4.0+ | no | no | 8.0+ | 1.3+

  For examples, see the quirksmode test page:

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

See Also

  outerHTML|innerText

ownerDocument : Object Reference to the document that contains the element. | Show Details | 6.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

parentElement : Object Reference to the direct parent element of the element. | No Details | 4.0+ | no | no | no | no

parentNode : Object Reference to the direct parent node of the element, if it exists. | Show Details | 4.0+ | 1.0+ | 6.0+ | 4.0+ | 1.0+

  For examples, see the quirksmode test page:

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

See Also

  parentElement

Availability

  HTML DOM Level 1

parentTextEdit : Object Reference to the closest parent element to the current element that can create a TextRange that contains the current element. | No Details | 4.0+ | no | no | no | no

prefix : String Prefix XML name for the element. | No Details | no | 1.0+ | no | 4.0+ | 1.0+

previousSibling : Object Reference to the previous sibling element of the element, if it exists. | Show Details | 5.0+ | 1.0+ | 6.0+ | 4.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

readyState : String Current readiness state of the element. See Remarks for possible values. | Show Details | 4.0+ | no | no | no | no

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

recordNumber : Number Record number for the data set that generated the element. | No Details | 4.0+ | no | no | no | no

runtimeStyle : Number Reference to the Style object specifying the current runtime style(s) of the element. | No Details | 5.0+ | no | no | no | no

scopeName : String XML scope of the element. | No Details | 5.0+ | no | no | no | no

scrollHeight : Number Height (in pixels) of the total content area of the element. | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

scrollLeft : Number Number of pixels between the actual left edge of the element to the displayed left edge of the element. | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

scrollTop : Number Number of pixels between the actual top edge of the element to the displayed top edge of the element. | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

scrollWidth : Number Width (in pixels) of the total content area of the element. | No Details | 4.0+ | 1.0+ | 7.0+ | 7.0+ | 1.0+

sourceIndex : Number Index of the element in the Document.all[] array. | Show Details | 4.0+ | no | no | 8.0+ | no

  For examples, see the quirksmode test page:

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

style : HTMLStyleObject Reference to the inline CSS style for the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 2

syncMaster : Boolean If true, indicates that the time container of the element must synchronize playback with the element. Default is false. | No Details | 5.5+ | no | no | no | no

tabIndex : Number Indicates the tab order index for the element. | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

tagName : String HTML tag name for the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 8.0+ | 1.3+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1

tagURN : String URN for the XML Namespace of the element. | No Details | 5.0+ | no | no | no | no

timeContainer : String Gets or sets the type of timeline that corresponds to the element. | No Details | 5.5+ | no | no | no | no

title : String Value of the title attribute for the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 2|W3C

uniqueID : String System-generated unique identifier for the element. | No Details | 5.5+ | no | no | no | no

## Properties

Property | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
disabled : Boolean If true, indicates that the element is disabled. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

form : HTMLFormElement The form that contains this element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

length : Number Number of Option elements that this Select element contains. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

multiple : Boolean If true, indicates that the user can select multiple options. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

name : String Name of the Select element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

  For examples, see the quirksmode test page:

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

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

options : HTMLCollection Array of HTMLOptionElement objects that this Select element contains. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

selectedIndex : Number Index for the currently selected Option element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

size : Number Number of options to display at a time. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

tabIndex : Number Position of the element in the tabbing order for the document. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

type : String If, multiple=true, then the value for type is "select-multiple." Otherwise, "select-one." | Show Details | 4.0+ | 1.0+ | 3.0+ | 7.0+ | 1.0+

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

## Inherited Functions

Method | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
addBehavior(String url) : HTMLElement Attaches a behavior to the element as specified in url. | Show Details | 5.0+ | no | no | no | no

Parameters

String | url | Reference to the behavior to attach.

Returns

HTMLElement |

addEventListener(String whichEvent, Object handler, Boolean direction) : HTMLElement Attaches an event listener to an HTMLElement that executes a function when the specified event occurs. | Show Details | no | 1.0+ | no | 7.0+ | 1.0+

Parameters

String | whichEvent | Event to trigger the specified function.
Object | handler | Function to execute when the specified event occurs.
Boolean | direction | Specify true to fire the event during the capture phase. Specify false to fire the event during the bubbling phase.

Returns

HTMLElement |

  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. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

- IE: Appending an "option" element to a "select" element may crash IE 5.0 on Windows.

Parameters

Node | newChild | Node to add to the current element as a child.

Returns

HTMLElement |

  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. | Show Details | 5.5+ | no | no | no | no

Parameters

String | newElement | Tag name of the element to add.
String | where | (optional)Specifies 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.

Returns

HTMLElement |

  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. | Show Details | 5.0+ | no | no | 8.0+ | no

Parameters

String | whichHandler | Event handler to attach.
String | theFunction | Function to attach to the event handler.

Returns

void |

  For examples, see the quirksmode test page:

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

blur() : void Removes focus from the element. | Show Details | 5.0+ | 1.0+ | 3.0+ | 7.0+ | 1.0+

Returns

void |

Availability

  HTML DOM Level 1

clearAttributes() : void Removes all attributes and values from the element. | Show Details | 5.0+ | no | no | no | no

Returns

void |

  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. | Show Details | 4.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Returns

void |

cloneNode(Boolean cloneChildren) : Node Clones a node and returns the new node. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

- IE: On a Mac, IE 5.0 does not clone the event handlers for an element.

Parameters

Boolean | cloneChildren | If true, specifies that any child nodes of the node should also be cloned.

Returns

Node |

  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. | Show Details | 5.0+ | no | no | no | no

Parameters

Boolean | x | X-coordinate (in pixels).
Boolean | y | Y-coordinate (in pixels).

Returns

String |

contains(Boolean element) : Boolean Returns true if the HTMLElement contains the specified element. | Show Details | 5.0+ | no | no | 8.0+ | no

Parameters

Boolean | element | Element to check for.

Returns

Boolean |

  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. | Show Details | 5.0+ | no | no | 8.0+ | no

Parameters

Object | whichHandler | Event handler to detach.
Object | theFunction | Function to detach.

Returns

void |

  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. | Show Details | no | 1.0+ | 6.0+ | 7.0+ | 1.0+

Parameters

Boolean | event | Event to redirect.

Returns

void |

Availability

  HTML DOM Level 2

dragDrop() : void Fires a drag event on the element. | Show Details | 5.5+ | no | no | no | no

Returns

void |

fireEvent(Boolean handler, [Boolean event]) : void Fires an instance of the specified event. | Show Details | 5.5+ | no | no | no | no

Parameters

Boolean | handler | Event handler for the event.
Boolean | event | (optional)Event to fire.

Returns

void |

focus() : void Gives focus to the element. | Show Details | 5.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Returns

void |

Availability

  HTML DOM Level 2

getAdjacentText(String where) : String Gets the string of text in the position specified by where. | Show Details | 5.0+ | no | no | no | no

Parameters

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

Returns

String |

getAttribute(String attributeName) : String Gets the value of the specified attribute. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Parameters

String | attributeName | Name of the attribute.

Returns

String |

  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. | Show Details | 6.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Parameters

String | attributeName | Name of the attribute.

Returns

Node |

  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. | Show Details | 5.0+ | no | no | no | no

Returns

Object |

getClientRects() : Object Returns a collection of all of the TextRectangle objects contained by the element. | Show Details | 5.0+ | no | no | no | no

Returns

Object |

getExpression(String propertyName) : String Returns the property expression specified by propertyName. | Show Details | 5.0+ | no | no | no | no

Parameters

String | propertyName | Name of the property/attribute.

Returns

String |

hasAttribute(String name) : Boolean Determines if the given attribute exists on this element. | Show Details | no | 1.0+ | 6.0+ | 7.0+ | 1.3+

Parameters

String | name | Name of the attribute to check.

Returns

Boolean |

  ### 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. | Show Details | no | 1.0+ | 6.0+ | 7.0+ | 1.3+

Returns

Boolean |

  ### 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`.<property>NamedNodeMap.length</property> > 0`.
See Also

  HTMLElement.getAttribute|HTMLElement.hasAttribute|Node.attributes

Availability

  HTML DOM Level 2

hasChildNodes() : Boolean Returns true if the node has child nodes. | Show Details | 5.0+ | 1.0+ | 6.0+ | 8.0+ | 1.0+

Returns

Boolean |

  ### 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. | Show Details | 5.0+ | no | no | no | no

Parameters

String | where | Specifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
Element | element | Element to insert.

Returns

void |

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. | Show Details | 4.0+ | no | no | no | no

Parameters

String | where | Specifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
String | text | HTML text to insert.

Returns

void |

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. | Show Details | 4.0+ | no | no | no | no

Parameters

String | where | Specifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
String | text | Text string to insert.

Returns

void |

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. | Show Details | 5.0+ | 1.0+ | 6.0+ | 8.0+ | 1.0+

Parameters

Node | newChild | New child node to insert.
Node | refChild | Reference child node.

Returns

void |

  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. | Show Details | no | 1.0+ | 6.0+ | 8.0+ | 1.0+

Parameters

String | feature | Name of the feature.
String | version | (optional)Version of the feature.

Returns

Boolean |

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. | Show Details | 5.0+ | no | no | no | no

Parameters

Object | source | Source that supplies the attributes.
Boolean | preserve | (optional)If true, specifies that the id of the current element should be preserved.

Returns

void |

  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. | Show Details | N/A | 1.0+ | 6.0+ | 8.0+ | no

- IE: May crash IE 6.0.

Returns

void |

  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. | Show Details | 5.0+ | no | no | no | no

Returns

void |

removeAttribute(String name) : void Removes an attribute by name | Show Details | 6.0+ | 1.0+ | 6.0+ | 8.0+ | 1.0+

- IE: IE does not remove events.

Parameters

String | name | Name of the attribute to remove.

Returns

void |

  ### 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

removeEventListener(String type, EventListener listener, Boolean useCapture) : void Removes an event listener from an event target. | Show Details | no | 1.0+ | no | 7.0+ | 1.0+

Parameters

String | type | Type of event.
EventListener | listener | Event listener to be removed.
Boolean | useCapture | Specify "true" to remove a capturing event listener. Specify "false" to remove all other types of event listeners.

Returns

void |

  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. | Show Details | 5.0+ | no | no | no | no

Parameters

String | propertyName | Name of the property expression to remove.

Returns

void |

replaceAdjacentText(String where, String text) : void Replaces the current text adjacent to the element with the specified text. | Show Details | 5.0+ | no | no | no | no

Parameters

String | where | Specifies where to insert the element. Valid values are beforeBegin, afterBegin, beforeEnd, and afterEnd.
String | text | Text to replace the current text with.

Returns

void |

See Also

  HTMLElement.insertAdjacentText

replaceNode(Node newNode) : void Replaces the current node with the node specified in newNode. | Show Details | 5.0+ | no | no | no | no

Parameters

Node | newNode | Node to replace the current node with.

Returns

void |

  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. | Show Details | 4.0+ | 1.0+ | 7.0+ | no | no

Parameters

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

Returns

void |

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. | Show Details | 5.5+ | no | no | no | no

Returns

void |

setAttribute(String name, String value) : void Adds a new attribute. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

- IE: IE removes event attributes when you try to set style attributes.

Parameters

String | name | Name of the attribute to set.
String | value | String value of the attribute to set.

Returns

void |

  ### 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

setCapture([Boolean containerCapture]) : void Sets mouse capture to the element. | Show Details | 5.0+ | no | no | no | no

Parameters

Boolean | containerCapture | (optional)If true, specifies that events that originate in the container will be captured by the container.

Returns

void |

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. | Show Details | 5.0+ | no | no | no | no

Parameters

String | property | Name of the property to add the expression to.
String | expression | Expression to set.
String | language | (optional)Scripting language to use. Default is JScript. Other valid values are JavaScript and VBScript.

Returns

void |

See Also

  HTMLElement.removeExpression

swapNode(Node node) : Node Swaps the current node with the specified node in the document. | Show Details | 5.0+ | no | no | no | no

Parameters

Node | node | Node to swap this node with.

Returns

Node |

  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. | Show Details | no | no | 4.0+ | no | no

Parameters

String | property | Property to remove the watch point from.

Returns

void |

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. | Show Details | no | no | 4.0+ | no | no

Parameters

String | property | Property to set the watch point on.
String | handler | Handler to invoke when the specified property changes.

Returns

void |

## Functions

Method | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
add(HTMLElement element, HTMLElement before) : void Adds the specified option element to the options array at the specified position. | Show Details | 5.0+ | 1.0+ | 3.0+ | 7.0+ | 1.0+

Parameters

HTMLElement | element | Option element to add.
HTMLElement | before | Option element to add the new element before.

Returns

void |

  For examples, see the quirksmode test page:

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

See Also

  Select

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

blur() : void Removes focus from the element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Returns

void |

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

focus() : void Gives the element focus. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Returns

void |

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

remove(Number index) : void Removes the option at the specified index position. | Show Details | 5.0+ | 1.0+ | 3.0+ | 7.0+ | 1.0+

Parameters

Number | index | Index of the option element to remove.

Returns

void |

  For examples, see the quirksmode test page:

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

See Also

  Select

Availability

  HTML DOM Level 1|HTML DOM Level 2|W3C

## References

HTMLFormElement|HTMLOptionElement|Option|Select

## Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

text_javascript aptana_docs