# Option : HTMLElement
Return to: HTML DOM Level 0 index

Option in a Select list.

## Platform Support

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

## Constructors

Constructor | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
Option Constructor() : Option Creates a new instance of an Option object. | Show Details | 3.0+ | 1.0+ | 2.0+ | no | no

### Option() : Option

Creates a new instance of an Option object.

Returns

Option |

Visibility
  internal

## Inherited Properties

Property | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
onclick : Object Event handler for when a user clicks on the element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|Input.onclick|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

ondblclick : Object Event handler for when a user double-clicks the element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

onhelp : Object Event handler for when a user requests Help. | Show Details | 3.0+ | no | no | no | no

Availability

  Internet Explorer 4

onkeydown : Object Event handler for when a user presses a key on his or her keyboard. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|HTMLElement.onkeypress

Availability

  JavaScript 1.2|HTML 4.0

onkeypress : Object Event handler for when a user presses and releases a key on his or her keyboard. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event

Availability

  JavaScript 1.2|HTML 4.0

onkeyup : Object Event handler for when a user releases a key on his or her keyboard. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|HTMLElement.onkeydown

Availability

  JavaScript 1.2|HTML 4.0

onmousedown : Object Event handler for when a user clicks the mouse button. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|HTMLElement.onclick|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

onmousemove : Object Event handler for when a user moves the mouse. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|Window.captureEvents|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

onmouseout : Object Event handler for when a user moves the mouse off of the element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|Link.onmouseout|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

onmouseover : Object Event handler for when a user moves the mouse over the element. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|Link.onmouseover

Availability

  JavaScript 1.2|HTML 4.0

onmouseup : Object Event handler for when a user releases the mouse button. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

See Also

  Event|HTMLElement.onclick|EventListener|EventTarget|MouseEvent

Availability

  JavaScript 1.2|HTML 4.0

all : Array List of all elements within the current element. Behaves similarly to document.all. | No Details | 4.0+ | no | no | 7.0+ | no

children : Array The direct child elements of the current element. | No Details | 4.0+ | no | no | no | no

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

Availability

  W3C

document : Object Reference to the Document object that contains the current element. | No Details | 4.0+ | no | no | no | no

id : String Identifier used to assign a unique name to the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  W3C

innerHTML : String HTML text that the element contains. (Does not include opening and closing tags of the element.) | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

innerText : String Plain text that the element contains. (Does not include opening and closing tags of the element.) | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

lang : String lang attribute of the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Availability

  W3C

offsetHeight : Object Height (in pixels) of the element and its contents. | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

offsetLeft : Object Horizontal position (in pixels) of the element relative to the offsetParent container element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

See Also

  offsetParent

offsetParent : Object Container element used as a reference for the offsetLeft and offsetTop elements. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

See Also

  offsetLeft|offsetTop

offsetTop : Object Vertical position (in pixels) of the element relative to the offsetParent container element. | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

offsetWidth : Object Width (in pixels) of the element and its contents. | No Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

outerHTML : String HTML text that the element contains, including its start and end tags. | No Details | 4.0+ | no | no | 7.0+ | no

outerText : String Plain text that the element contains, including its start and end tags. | No Details | 4.0+ | no | no | 7.0+ | no

parentElement : Object Element that is the direct parent of the current element. | No Details | 4.0+ | no | no | no | no

sourceIndex : Object Index of the current element in document.all. | No Details | 4.0+ | no | no | no | no

style : Object Inline CSS style attributes for the element. | No Details | 4.0+ | 1.0+ | 4.0+ | 7.0+ | 1.0+

tagName : String HTML tag name for the element. | No Details | 5.5+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

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

Availability

  W3C

## Properties

Property | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
defaultSelected : Boolean Whether or not the option is selected by default. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  W3C

index : Number Index in the options array for the option. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  W3C

selected : Boolean Whether or not the option is currently selected. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  W3C

text : String Text for the option. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  W3C

value : String Value of the option that is sent when the form is submitted. | Show Details | 3.0+ | 1.0+ | 2.0+ | 7.0+ | 1.0+

Availability

  W3C

## Inherited Functions

Method | Action | IE | Mozilla | Netscape | Opera | Safari
--- | --- | --- | --- | --- | --- | ---
contains(Object target) : Boolean Determines whether the current element contains the target HTML element. | Show Details | 4.0+ | no | no | no | no

Parameters

Object | target | The HTML element that the element is to be compared with.

Returns

Boolean |

Availability

  Internet Explorer 4

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

Parameters

String | name | Name of the attribute.

Returns

String |

Availability

handleEvent() : Object Calls the event handler for the specified event. | Show Details | no | no | 6.0+ | no | no

Returns

Object |

See Also

  window.handleEvent|document.handleEvent

insertAdjacentHTML(String where, Object text) : void Inserts HTML text in the specified location within or next to the element. | Show Details | 5.0+ | no | no | 7.0+ | no

Parameters

String | where | Specifies where the HTML text should be inserted.
Object | text | The HTML text to insert.

Returns

void |

insertAdjacentText(String where, Object text) : void Inserts plain text in the specified location within or next to the element. | Show Details | 5.0+ | no | no | 7.0+ | no

Parameters

String | where | Specifies where the text should be inserted.
Object | text | The plain text to insert.

Returns

void |

removeAttribute(String name) : Attribute Deletes the specified attribute from the element. | Show Details | 6.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Parameters

String | name | Name of the attribute to be removed.

Returns

Attribute |

scrollIntoView([Boolean top]) : void Scrolls the current document so that the top of current element is either at the top of the display area, or the bottom of the element is at the bottom of the display area. | Show Details | 4.0+ | 1.0+ | 7.0+ | no | no

Parameters

Boolean | top | (optional)Specify false to align the bottom of the element with the bottom of the display area. Specify true or nothing to align the top of the element with the top of the display area.

Returns

void |

setAttribute(String name, Object value) : Object Sets the specified attribute to the specified value for the element. | Show Details | 4.0+ | 1.0+ | 6.0+ | 7.0+ | 1.0+

Parameters

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

Returns

Object |

Availability

  HTML DOM Level 1

## References

Select|Select.options[]|HTMLOptionElement|HTMLSelectElement

## Availability

JavaScript 1.0|enhanced in JavaScript 1.1|W3C

text_javascript aptana_docs