我怎么知道通过jQuery选择了哪个单选按钮?
jQuery:Checked选择器可与结合使用,val()以查找某些单选按钮的值,
$('input[name=radioName]:checked').val()在您的查询中,可以实现为-
示例
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input[type='button']").click(function() {
var radioValue = $("input[name='q1']:checked").val();
if(radioValue) {
alert("You select - " + radioValue);
}
});
});
</script>
</head>
<body>
<form action="">
Select a number:<br>
<input type="radio" name="q1" value="1">1
<input type="radio" name="q1" value="2">2
<input type="radio" name="q1" value="3">3
</form>
<p><input type="button" value="submit"></p>
</body>
</html>热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短