Section 25.258. Select.options: the choices in a Select object


25.258. Select.options[]: the choices in a Select object

DOM Level 2 HTML

25.258.1. Synopsis

 readonly HTMLCollection options 

25.258.2. Description

The options[] property is an array-like HTMLCollection of Option objects. Each Option object describes one of the selection options presented within the Select object.

The options[] property is not an ordinary HTMLCollection. For backward compatibility with the earliest browsers, this collection has certain special behaviors that allow you to change the options displayed by the Select object:

  • If you set options.length to 0, all options in the Select object are cleared.

  • If you set options.length to a value less than the current value, the number of options in the Select object is decreased, and those at the end of the array disappear.

  • If you set an element in the options[] array to null, that option is removed from the Select object, and the elements above it in the array are moved down, changing their indices to occupy the new space in the array (see also Select.remove( )).

  • If you create a new Option object with the Option( ) constructor (see Option), you can add that option to the end of the options list in the Select object by appending it to the options[] array. To do this, set options[options.length] (see also Select.add( )).

25.258.3. See Also

Option




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net