在Javascript中如何删除select类型中的所有元素 好像没有removeall,用for循环一个一个remove吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <select name=select1> <option value=1>1 <option value=2>2</selct><input type=button onclick="hoho()" value=吼吼><script>function hoho(){ document.all.select1.options[document.all.select1.selectedIndex]=null;}</script> for (i=select.options.length-1;i>=0;i--){ select.options.remove(i);} document.all.sel.options.length = 0; //sel为select的name <form name="form1"><select size="8" name="selUser" style="width:250" multiple><option name="1" value="1">1</option><option name="5" value="5">5</option></select><input type="button" name="del" value="delme" onclick="delall()"></form><script language="Javascript">function delall(){ var ln = form1.selUser.options.length; alert(ln); form1.selUser.multiple = false; while (ln--) form1.selUser.options.remove(ln);}</script> form1.selUser.innerHTML = "" <script>function delall(){var selUser=document.getElementsByName("selUser")for(i=0;i<selUser[0].length;i++){selUser[0].options[i]=new Option("","")}}</script><select name="selUser"><option name="1" value="1">1</option><option name="2" value="2">2</option><option name="3" value="3">3</option><option name="4" value="4">4</option><option name="5" value="5">5</option><option name="6" value="5">6</option></option><input type="button" name="del" onclick="delall()" value="清除值"> 请一个Jquery生成表格的问题。 帮助修改日历控件, 谢谢! js闭包问题 轮显图片在FF下不显示 window.open()的问题 firefox中如何处理long类型啊 看看这2段 JavaScript 代码有什么区别? 请问如何给汉字排序?(20分) 请教JQuery easyui-tree的一个问题 大神们来看看这个json串 收集时钟代码,要求还指针的那种。 函数之间的值能相互传递吗?为何这段程序不行哩?
<option value=1>1
<option value=2>2
</selct>
<input type=button onclick="hoho()" value=吼吼>
<script>
function hoho(){
document.all.select1.options[document.all.select1.selectedIndex]=null;
}
</script>
{
select.options.remove(i);
}
<select size="8" name="selUser" style="width:250" multiple>
<option name="1" value="1">1</option>
<option name="5" value="5">5</option>
</select>
<input type="button" name="del" value="delme" onclick="delall()">
</form><script language="Javascript">
function delall(){
var ln = form1.selUser.options.length;
alert(ln);
form1.selUser.multiple = false;
while (ln--)
form1.selUser.options.remove(ln);
}
</script>
function delall(){
var selUser=document.getElementsByName("selUser")for(i=0;i<selUser[0].length;i++){selUser[0].options[i]=new Option("","")}
}
</script>
<select name="selUser">
<option name="1" value="1">1</option>
<option name="2" value="2">2</option>
<option name="3" value="3">3</option>
<option name="4" value="4">4</option>
<option name="5" value="5">5</option>
<option name="6" value="5">6</option>
</option>
<input type="button" name="del" onclick="delall()" value="清除值">