jQuery查询select框中的值

来源:互联网 发布:国外足球预测网站 知乎 编辑:程序博客网 时间:2024/06/05 07:50

用jQuery查找select框下option中value值和显示的值。
代码如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><title>菜鸟教程(runoob.com)</title><script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script><script>$(document).ready(function(){    $("button").on("click",function(){         debugger;        var aa = $("#test1").val();        alert(aa);        var bb = $("#test1").find("option:selected").text();        alert(bb);    });}); </script></head><body><select id="test1">  <option value="1">第一行</option>  <option value="2">第二行</option>  <option value="3">第三行</option></select><button>点我</button></body></html>
原创粉丝点击