Javascript Reference
Categories: options

javascript options remove( )

@March 15, 2008, 1:22 a.m.
remove( )Firefox/Netscape/NN n/a IE 4 Chrome/Safari/DOM n/a  

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.

 
Parameters
 
  • A zero-based integer indicating which item in the collection should be deleted.
 
Returned Value

None.


Powered by Linode.