获取 input 单选框和多选框的值

 引用  jQuery的js 

 1  <script>
 2  $(function(){
 3 
 4     var arr = new Array();
 5 
 6     $('#checkbox').click(function(){
 7         arr = [];
 8 
 9         $("input[name='c']:checked").each(function(k,v){
10             arr.push($(this).val());
11         });
12 
13         $('#arr').val(arr);
14     });
15 
16     $('#radio').click(function(){
17         var vradio = $('input[name="r"]:checked').val();
18         alert(vradio);
19     });
20  });
21  
22  </script>

html

 1 <body>
 2    <input type="checkbox" name="c" value="c1" id="" />c1
 3    <input type="checkbox" name="c" value="c2" id="" />c2
 4    <input type="checkbox" name="c" value="c3" id="" />c3
 5    <input type="text" name="" value="" id="arr" />c3
 6    <input type="button" value="checkbox" id="checkbox"/><br>
 7 
 8    <input type="radio" name="r" value="r1" id="" />r1
 9    <input type="radio" name="r" value="r2" id="" />r2
10    <input type="radio" name="r" value="r3" id="" />r3
11    <input type="button" value="radio" id="radio"/>
12 </body>
原文地址:https://www.cnblogs.com/hjwbla/p/5165552.html