Name

remove( ) — NN n/a IE 4 DOM n/a

Synopsis

remove(index)

Deletes an element from the current collection. Simply specify the zero-based index value of the OPTION element you wish to remove from the collection belonging to a SELECT element. The following example deletes the first item from a SELECT object:

document.forms[1].rockers.options.remove(0)

The process for removing an OPTION element is entirely different in Navigator. To delete an item, assign null to the item in the collection. For example, the Navigator version of the preceding IE example is as follows:

document.forms[1].rockers.options[0] = null

Regardless of the browser-specific process of removing an option from the SELECT object, the length of the options array collapses to fill the space.

Returned Value

None.

Parameters

index

A zero-based integer indicating which item in the collection should be deleted.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

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