js 獲取select的值


var t = document.getElementById("provid");


console.log(t.value);

console.log(t.text); //未定義

console.log(t.selectedIndex); //有效

var text = t.options[t.selectedIndex].text; // 選中文本
var value = t.options[t.selectedIndex].value; // 選中值

console.log(text);
console.log(value);

 

                    var select_options = document.getElementById("typeid").options;
                    for (var i = 0; i < select_options.length; i++) {
                        if (select_options[i].value == type_id) {
                            select_options[i].selected = true;
                            break;
                        }
                    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM