Home  >  Article  >  Web Front-end  >  javascript删除option选项的多种方法总结_javascript技巧

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

WBOY
WBOYOriginal
2016-05-16 17:13:141184browse
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);   
}  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn