-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (39 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$(function () {
$(".btn").on("click", function () {
$(this).closest("div").css("display", "none");
id = $(this).attr("href");
$(id).addClass("fit").fadeIn("slow").show();
});
//選択ボタンデータを配列に入れてカウントする関数
var countA;
var countB;
var countC;
var box = [];
$(".btn").each(function () {
$(this).on('click', function () {
var value = $(this).data("value");
box.push(value);
countA = box.filter(function (x) {
return x === "a"
}).length;
countB = box.filter(function (y) {
return y === "b"
}).length;
countC = box.filter(function (y) {
return y === "c"
}).length;
});
});
//結果を出力する関数
$('.end').on('click', function () {
if (countA > countB) {
$('#answer_01').css("display", ""); //回答1
} else {
if (countB > countC) {
$('#answer_02').css("display", ""); //回答2
} else {
$('#answer_03').css("display", ""); //回答3
}
}
});
});