Select下拉框onchange事件获取option的value值

来源:互联网 发布:上海网络教育哪里报名 编辑:程序博客网 时间:2024/05/16 05:45
<select name="type" onchange="show_sub(this.options[this.options.selectedIndex].value)">      <option value="0">请选择主类别</option>      <option value="1">1</option>      <option value="2">2</option>   </select>



show_sub的JS方法:


<script>       function show_sub(v){           alert(v);       }   </script>  

最重要的知识点是获在select onchange时获取option的value值:

this.options[this.options.selectedIndex].value

转自:http://blog.micxp.com/index.php/archives/54/

2 0
原创粉丝点击