'remove()' Example : remove « Javascript Methods « JavaScript Reference

'remove()' Example

<!-- 
Example revised from 

The Web Programmer's Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen 

ISBN: 1593270119
Publisher: No Starch Press 2004
-->   
<html>
<body>
<script language="JavaScript">
    function function1() {
        var newOption = document.createElement('<option value="TOYOTA">');
        document.all.mySelect.options.add(newOption);
        newOption.innerText = "Toyota";
    }
    function function2() {
        document.all.mySelect.options.remove(0);
    }
</script>
<select id="mySelect">
    <option value="HONDA">Honda</option>
    <option value="ACURA">Acura</option>
    <option value="LEXUS">Lexus</option>
</select>
<input type="button" value="Add" onclick="function1();">
<input type="button" value="Remove" onclick="function2();">
</body>
</html>

    
      
      








Related examples in the same category

1.'remove()' Syntax, Parameters and Note
2.'remove()' is applied to