js select 改变当前选中option


这个方法虽然简单,但值得记录一下,原来的是select.options[i].value 我改成了 select.options[i].text ,根据自己需要
function set_select_checked(selectId, checkValue){
var select = document.getElementById(selectId);

for (var i = 0; i < select.options.length; i++){
if (select.options[i].text == checkValue){
select.options[i].selected = true;
break;
}
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM