js 获取select的值
生活随笔
收集整理的這篇文章主要介紹了
js 获取select的值
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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 = ; i < select_options.length; i++) {
if (select_options[i].value == type_id) {
select_options[i].selected = true;
break;
}
}
總結(jié)
以上是生活随笔為你收集整理的js 获取select的值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 云服务器——之Linux下安装nginx
- 下一篇: 【python系统学习14】类的继承与创