码迷,mamicode.com
首页 > 其他好文 > 详细

jquary获取单选,多选,select的值

时间:2016-08-28 19:23:57      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

 1 <%@ page contentType="text/html; charset=UTF-8"%>
 2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 3 <html>
 4 <head>
 5 <script src="component/jquery-1.11.1.js"></script>
 6 <script>
 7 $(document).ready(function() {
 8     $("[name=‘radioGroup‘]").on("change",function() {
 9         var radioValue = $(this).val();
10         $("#radioText").text("单选按钮的值:"+radioValue);
11     });
12     
13     $("[name=‘checkGroup‘]").on("change",function() {
14         var array = new Array();
15         $("[name=‘checkGroup‘]:checked").each(function(){
16             var cbVal = $(this).val();
17             array.push(cbVal);
18         });
19         
20         $("#checkBoxText").text("多选按钮的值:" + array.join(","));
21         if ($("[name=‘checkGroup‘][value=‘1‘]").is(:checked)) {
22             $("#checkBoxText1").text("多选按钮1被选中");
23         } else {
24             $("#checkBoxText1").text("");
25         }
26     });
27     
28     $("[name=‘selectGroup‘]").on("change",function() {
29         $("#selectText").text($(this).val());
30     });
31     
32     $("[name=‘selectGroup1‘]").on("change",function() {
33         $("#selectText1").text($(this).val());
34     });
35 });
36 </script>
37 </head>
38 <body>
39     <input type="radio" name="radioGroup" value="1" />单选按钮1
40     <input type="radio" name="radioGroup" value="2" />单选按钮2
41     <br>
42     <font color="red" id="radioText"></font>
43     <hr/>
44     <input type="checkbox" name="checkGroup" value="1"/>多选按钮1
45     <input type="checkbox" name="checkGroup" value="2"/>多选按钮2
46     <input type="checkbox" name="checkGroup" value="3"/>多选按钮3
47     <br>
48     <font color="red" id="checkBoxText"></font><br>
49     <font color="red" id="checkBoxText1"></font>
50     <hr/>
51     <select name="selectGroup">
52         <option value="1">select1</option>
53         <option value="2">select2</option>
54         <option value="3">select3</option>
55     </select>
56     <br>
57     <font color="red" id="selectText"></font>
58     <hr/>
59     <select name="selectGroup1" multiple="multiple">
60         <option value="1">select1</option>
61         <option value="2">select2</option>
62         <option value="3">select3</option>
63     </select>
64     <br>
65     <font color="red" id="selectText1"></font>
66 </body>
67 </html>

 

jquary获取单选,多选,select的值

标签:

原文地址:http://www.cnblogs.com/sun-space/p/5815582.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!