Jquery 获取单选、多选(radio、checkbox)选中值

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>test.html</title>
        <meta charset="utf-8" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>

		
<script>
$(document).ready(function(){
  $("button").click(function(){
      var r = $("input[name='radio_button']:checked").val();
       alert(r);
    $("#result").text(r);//获取值
  });
});
</script>
</head>

<body>


			<input type="radio" name="radio_button" value="radio_button_1" />1
			<input type="radio" name="radio_button" value="radio_button_2" />2
			<input type="radio" name="radio_button" value="radio_button_3" />3
            <button>显示值</button>
<div id="result"></div>
	</body>
</html>


复选也是一样子的取得值:

http://blog.csdn.net/haibo0668/article/details/72123497

没有更多推荐了,返回首页