方法一:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>getSelectValue</title>
<script src="js/jquery-1.5.1.min.js"></script>
</head>
<body>
<select id="s_a">
<option>java</option>
<option>.net</option>
<option>php</option>
</select>
<input type="button" value="click" οnclick="alert(fetSelectVal();)"/>
</body>
<script>
var _select = document.getElementById("s_a");
function getSelectVal(){
var idx = _select.selectedIndex,
option,
value;
if (idx > -1) {
option = _select.options[idx];
value = option.attributes.value;
return (value && value.specified) ? option.value : option.text;
}
return null;
}
</script>
</html>
方法二:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>getSelectValue</title>
<script src="js/jquery-1.5.1.min.js"></script>
</head>
<body>
<select id="s_a">
<option>java</option>
<option>.net</option>
<option>php</option>
</select>
<input type="button" value="click" οnclick="alert($('#s_a').find('option:selected').text());"/>
</body>
</html>