js获取<select>下拉菜单的value值和text值

来源:互联网 发布:c windows.h 编辑:程序博客网 时间:2024/05/16 14:48
<script type="text/javascript">window.onload = function(){//获取所选项的text值document.getElementById("fl").onchange= function(){alert(this.options[this.selectedIndex].text);};//获取所选项的value值document.getElementById("fl").onchange= function(){//alert(this.options[this.selectedIndex].value);也可以这样写alert(this.value);};}</script>


原创粉丝点击