var select_dept = document.getElementById("_deptid"); var opt = select_dept = opt.getElementsByTagName("option"); for(var i = 0 ; i < opt.length ; i ++){ //遍历option数组 if(opt[i].value.indexOf(typeName1) != -1){ //如果值等于目标值,则选中目标值 opt[i].selected = true; break;
}
}