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