<select name=s1 id=s1>
<option value=1>1</option>
<option value=2>2</option>
</select><script>  var objs=document.getElementById('s1')
  var i=objs.options.length-1
  while i>=0 {
   objs.options.remove(i);
   i--;
}
</script>上面的代码在firefox中不能用。
怎么办

解决方案 »

  1.   

    <select name=s1 id=s1>
    <option value=1>1</option>
    <option value=2>2</option>
    </select><script>var objs=document.getElementById('s1')
    var i=objs.options.length-1
    while i>=0 {
    objs.options.remove(i);
    i--;
    }
    </script>
    -----objs.option.length = 0
      

  2.   


    <script>
      function f1()
      {
      var objs=document.getElementById("s1");
      var i=objs.options.length-1;   while (i>=0)
       {
       
       var node=document.getElementById("option"+i);
       node.parentNode.removeChild(node);
       i--;
       }  }
    </script><select name=s1 id=s1>
    <option value=1 id="option1">1</option>
    <option value=2 id="option0">2</option></select>
    <input type=button  onclick="f1()" value="ooooo">
      

  3.   

    MF中节点没有removeNode方法,必须使用如下方法 node.parentNode.removeChild(node)
      

  4.   

    直接用
    objs.option.length = 0
    即可
      

  5.   

    objs.length = 0;
    即可.
      

  6.   

    var i=objs.options.length-1;
    怎么这条也不行??
      

  7.   

    objs.option.length = 0
    不行啊 老大!
      

  8.   

    var objs=document.getElementById("s1")
      var i=objs.options.length-1  alert(i)
      i显示为1