遍历select下拉框判断其中值是否与指定值相等

来源:互联网 发布:手机脱壳软件 编辑:程序博客网 时间:2024/06/05 20:33
//===========================遍历select下拉框判断其中值是否与指定值相等  start==============================
var obj = document.getElementsByTagName("option")
//遍历option
for(var i=0;i<obj.length;i++){
if(obj[i].value==你的指定值){
obj[i].selected=true;  //相等则选中
}
}
//===========================遍历select下拉框判断其中值是否与指定值相等  start==============================
0 0