1、通过jQuery取select的值,源码如下:
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>取select的值</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> <script type="text/javascript" src="../script/jquery-1.10.2.js"></script> <script type="text/javascript"> $(function(){ $("#yhd_select").each(function(){ $("#yhd_select").change(function(){ //取select中的option的value值 alert($("#yhd_select").val()); //取select的文本值 alert($("#yhd_select option:selected").text()); }); }); }); </script> </head> <body> <div id="yhd_div"> <label>地市:</label> <select id="yhd_select"> <option value="0">全部</option> <option value="1">武汉市</option> <option value="2">黄石市</option> <option value="3">十堰市</option> <option value="4">荆州市</option> <option value="5">宜昌市</option> <option value="6">襄阳市</option> <option value="7">鄂州市</option> <option value="8">荆门市</option> <option value="9">黄冈市</option> <option value="10">咸宁市</option> <option value="11">随州市</option> <option value="12">孝感市</option> </select> </div> </body> </html>
2、运行结果
(1)初始化时
(2)选择“武汉市”时
(3)单击“确定”后
作者:you23hai45 发表于2013-12-20 23:42:54 原文链接
阅读:135 评论:1 查看评论