Js与下拉列表处理问题解决

网络编程 发布日期:2024/10/9 浏览次数:1

正在浏览:Js与下拉列表处理问题解决

复制代码 代码如下:
var obj=document.getElementByIdx("test");
if(0<obj.options.length){
//obj.options.remove(obj.selectedIndex); //IE 可用
obj.options[obj.selectedIndex]=null;//IE FF 均可
for(var i=0;i<obj.options.length;i++){//for 只为重新排序...可以忽略
obj.options[i].text="子项"+i;
obj.options[i].value=i;
}
if(0<obj.options.length){//第一项选择状态
obj.options[0].selected=true;
}
}