<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<select name="selectNum" id="selectNum" οnchange="show(this.text);">
<option value="" selected="selected">--请选择--</option>
<option value="A">this is content zero;</option>
<option value="B">this is content one;</option>
<option value="C">this is content two;</option>
<option value="D">this is content three;</option>
</select>
<script type="text/javascript">
// var select_obj = document.getElementsByName("selectNum")[0];
var select_obj=document.getElementById("selectNum");
select_obj.options[3].style.backgroundColor = 'red';
function show(index){
var num=select_obj.selectedIndex;
alert(select_obj.options[num].text);
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<select name="selectNum" id="selectNum" οnchange="show(this.text);">
<option value="" selected="selected">--请选择--</option>
<option value="A">this is content zero;</option>
<option value="B">this is content one;</option>
<option value="C">this is content two;</option>
<option value="D">this is content three;</option>
</select>
<script type="text/javascript">
// var select_obj = document.getElementsByName("selectNum")[0];
var select_obj=document.getElementById("selectNum");
select_obj.options[3].style.backgroundColor = 'red';
function show(index){
var num=select_obj.selectedIndex;
alert(select_obj.options[num].text);
}
</script>
</body>
</html>