js清空select的所有option

字號:


    這是網(wǎng)上找到的方法,兩種都可以用不過第二種還是比較方便的
    第一種:<select name=mySelect>
    <option value=1>1</option>
    <option value=2>2</option>
    </select>
    <script language="javascript">
    var theSelect=document.all.mySelect;
    for(var i=theSelect.options.length-1;i>=0;i--)
    theSelect.options.remove(i);
    </script>
    第二種:document.getElementById("selectIDname").innerHTML = "";