select 获取value及选中值
2017-12-06 本文已影响5人
sky丶星如雨
html
<select name="" id="sel">
<option value="1">苹果</option>
<option value="2">橘子</option>
<option value="3">草莓</option>
<option value="4">芒果</option>
</select>
script
var sel = document.getElementById("sel");
sel.onchange = function () {
var index = this.selectedIndex;
console.log(this.value);
console.log(this.options[index].text);
}