remove method (select)
Removes the specified option element or the option element at the specified position from the options collection of the current select element.
This method is identical to the remove method of the options collection, but the remove method is not supported by Firefox.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. A zero-based integer that specifies the position of the element or a reference to the option element to remove.
Note: Only integer values are supported for this parameter in Opera.
For a cross-browser solution, if you want to remove an option element by reference, use the removeChild method.
|
Return value:
This method has no return value.
Example HTML code 1:
This example illustrates the use of the remove method:
|
||||
<head> <script type="text/javascript"> function RemoveFirstOption () { var selectTag = document.getElementById ("mySelect"); selectTag.remove (0); } </script> </head> <body> <select id="mySelect" size="5"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> <button onclick="RemoveFirstOption ()">Remove the first option</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
External links:
User Contributed Comments