<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
$('div :radio:checked').each(function (index, ele) {
alert($(ele).val());
})
})
$('#btn2').click(function () {
//$(':radio[value=1]').attr('checked', true);//单旋钮选中
$(':radio').val([1, 2]);//两个单旋钮选中
})
})
</script>
</head>
<body>
<input type="button" name="name" value="显示选中的值" id="btn" />
<input type="button" name="name" value="选中男" id="btn2" />
<div>
<input type="radio" name="name1" value="1" />男
<input type="radio" name="name2" value="2" />女
<input type="radio" name="name3" value="3" checked="checked"/>保密
</div>
</body>
</html>