this.selectedIndex;
this.options[_index].text;
this.options[_index].value;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js获取select选中值</title>
<style type="text/css">
body{
padding-left: 100px;
}
div{
margin: 10px 0;
}
</style>
</head>
<body>
<select id="one">
<option>11111</option>
<option>22222</option>
<option>33333</option>
</select>
<div class="one"></div>
<select id="two" multiple="true">
<option>11111</option>
<option>22222</option>
<option>33333</option>
</select>
<div class="two"></div>
<script>
var one = document.getElementById('one');
one.addEventListener('change', function() {
var _index = this.selectedIndex;
var _text = this.options[_index].text;
var _value = this.options[_index].value;
document.getElementsByClassName('one')[0].innerText= "选中的索引是:"+_index
+ " 选中的文本是:"+ _text
+ " 选中的值是:" + _value;
})
var two = removeWhitespace(document.getElementById('two'));
two.addEventListener('change', function() {
var _two = document.getElementsByClassName('two')[0];
var str="";
var fid = two.childNodes;
for(var i = 0; i < fid.length; i++) {
if(fid[i].selected==true){
str += "选中索引:"+ fid[i].index + ",选中文本:"+fid[i].text + "选中值:" + fid[i].value +",";
}
}
_two.innerText = str;
})
function removeWhitespace(xml){
var loopIndex;
for (loopIndex = 0; loopIndex < xml.childNodes.length; loopIndex++){
var currentNode = xml.childNodes[loopIndex];
if (currentNode.nodeType == 1){
removeWhitespace(currentNode);
}
if (((/^\s+$/.test(currentNode.nodeValue))) &&(currentNode.nodeType == 3)){
xml.removeChild(xml.childNodes[loopIndex--]);
}
}
return xml;
}
</script>
</body>
</html>