Heim  >  Artikel  >  Web-Frontend  >  javascript删除option选项的多种方法总结_javascript技巧

javascript删除option选项的多种方法总结_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:13:141185Durchsuche
1、 JavaScript
复制代码 代码如下:

var oSel=document.form1.DropDownCity;
while(oSel.options.length>0){
oSel.removeChild(oSel.options[0]);
}

2、 JavaScript
复制代码 代码如下:



3、 JavaScript
复制代码 代码如下:



4、 JavaScript
复制代码 代码如下:



removeOption  在ie中的用法
复制代码 代码如下:

function removeOption(index)  
{   
    document.getElementById("selUnassignedUsers").options.remove(index);   
}  

removeOption  在FF中的用法
复制代码 代码如下:

function removeOption(index)   
{   
    document.getElementById("selUnassignedUsers").remove(index);   
}  
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn