以下是我的代码,想实现点击单选项,获取得分的需求,但是点击单选项的文字,得分会被计算两次,请问我的代码出现了什么问题?谢谢
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<label class="man"><input type="radio" name="sex" id="man">man</label>
<label class="woman"><input type="radio" name="sex" id="woman">woman</label>
<script src="JS/jquery-3.1.1.min.js"></script>
<script>
$(document).ready(function(){
var score = 0;
$(".man").click(function(){
score = score + 1;
console.log(score);
// score = 0;
});
$(".woman").click(function(){
score = score + 2;
console.log(score);
// score = 0;
});
})
</script>
</body>
</html>
米琪卡哇伊
相关分类