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