您的位置:首页 > Web前端 > JavaScript

JS 处理select下拉框信息总结

2013-05-15 15:52 295 查看
处理select信息:

var se = document.getElementById("select");

if(se.nodeName=='SELECT'){//判断标签

  alert(se.options[se.selectedIndex].value);//获取value

  alert(se.options[se.selectedIndex].text);//获取text

  se.options.add(new Option("qw","12"));//添加选项

  se.options.remove("qw");//删除选项

  se.options[0].selected=true;//默认选中第一项

}

for(var i = 0;i<se.options.length;i++){
if(se.options[i].value==code){
se.options[i].selected=true;
break;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  select