时间:2021-07-01 10:21:17 帮助过:3人阅读
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var text = param.value;
}
}
</script>
2.下拉框的option有value属性时
代码如下:
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var selectIndex = param.selectIndex; //获得被选项的引索号
var text = param.options[selectIndex].text;
</script>