Fork me on github

jquery获取radio和select选中值

//jquery 获取radio选中值

<input type="radio" name="c_type" value="a" >aaaa
<input type="radio" name="c_type" value="b" >bbbb
<input type="radio" name="c_type" value="c" >cccc 

<script src="jquery-2.1.4.min.js"></script>
<script>
  $('input[name="c_type"]').click( function () {
    var item = $("input[name='c_type']:checked").val(); 
    alert(item);
  });
</script>


//jquery 获取select选中值

<select name="c_type" id="select">
  <option value="a">aaaa</option>
  <option value="b">bbbb</option>
  <option value="c">cccc</option>
</select>

<script src="jquery-2.1.4.min.js"></script>
<script>
  $("#select").change(function(){
    var item = $("#select option:selected").val(); 
    alert(item);
  });
</script>

  

 

 

posted @ 2015-11-10 17:52  Champion-水龙果  阅读(260)  评论(0编辑  收藏  举报
Champion-水龙果