質問編集履歴
1
表示コードを部分的に変更しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,115 +14,17 @@
|
|
14
14
|
|
15
15
|
###該当のソースコード
|
16
16
|
```ここに言語を入力
|
17
|
-
<!DOCTYPE html>
|
18
|
-
<html lang="ja">
|
19
|
-
<head>
|
20
|
-
<meta charset="utf-8">
|
21
|
-
<title>Numeber Game</title>
|
22
|
-
<style>
|
23
|
-
body {
|
24
|
-
background: #e0e0e0;
|
25
|
-
font-family: Arial, sans-serif;
|
26
|
-
text-align: center;
|
27
|
-
color: #0088cc;
|
28
|
-
font-size: 16px;
|
29
|
-
}
|
30
|
-
#scoreArea {
|
31
|
-
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
32
|
-
margin: 30px auto;
|
33
|
-
}
|
34
|
-
#scoreText {
|
35
|
-
font-weight: bold;
|
36
|
-
font-size: 24px;
|
37
|
-
}
|
38
|
-
#startButton {
|
39
|
-
margin: 30px auto;
|
40
|
-
width: 180px;
|
41
|
-
border-radius: 5px;
|
42
|
-
box-shadow: 0 4px 0 #e91b0c;
|
43
|
-
background: #f44336;
|
44
|
-
color: #fff;
|
45
|
-
cursor: pointer;
|
46
|
-
padding: 7px;
|
47
|
-
}
|
48
|
-
#startButton:hover {
|
49
|
-
opacity: 0.8;
|
50
|
-
}
|
51
|
-
#startButton.pushed {
|
52
|
-
margin-top: 32px;
|
53
|
-
box-shadow: 0 2px 0 #e91b0c;
|
54
|
-
}
|
55
|
-
.btn {
|
56
|
-
display: inline-block;
|
57
|
-
width: 40px;
|
58
|
-
padding: 7px;
|
59
|
-
border-radius: 5px;
|
60
|
-
box-shadow: 0 4px 0 #0088cc;
|
61
|
-
color: #fff;
|
62
|
-
background: #00aaff;
|
63
|
-
cursor: pointer;
|
64
|
-
margin-bottom: 10px;
|
65
|
-
}
|
66
|
-
.btn + .btn {
|
67
|
-
margin-left: 10px;
|
68
|
-
}
|
69
|
-
.btn.inactive {
|
70
|
-
opacity: 0.5;
|
71
|
-
}
|
72
|
-
</style>
|
73
|
-
</head>
|
74
|
-
<body>
|
75
|
-
<div id="scoreArea">Your Score: <span id="scoreText">0.0</span></div>
|
76
|
-
<div id="board">
|
77
|
-
<!-- <div class="btn">0</div>
|
78
|
-
<div class="btn">1</div><br>
|
79
|
-
<div class="btn">2</div>
|
80
|
-
<div class="btn">3</div> -->
|
81
|
-
</div>
|
82
|
-
<div id="startButton" class="pushed">START</div>
|
83
|
-
<script>
|
84
|
-
(function() {
|
85
|
-
"use strict";
|
86
|
-
var size = 2;
|
87
17
|
|
88
|
-
var board = document.getElementById("board");
|
89
|
-
|
90
|
-
initBoard();
|
91
|
-
|
92
|
-
function createButton(num) {
|
93
|
-
var button;
|
94
|
-
button = document.createElement("div");
|
95
|
-
button.className = "btn";
|
96
|
-
button.innerHTML = num;
|
97
|
-
return button;
|
98
|
-
}
|
99
|
-
|
100
|
-
function initBoard() {
|
101
|
-
var buttons = [];
|
102
|
-
//buttons
|
103
|
-
//0,1,2,3
|
104
|
-
for (var i = 0; i < size * size; i++) {
|
105
|
-
buttons.push(createButton(i));
|
106
|
-
}
|
107
|
-
|
108
|
-
//シャッフル
|
109
|
-
//boardに追加
|
110
18
|
while (buttons.length) {
|
111
19
|
var buttons = buttons.splice(Math.floor(Math.random() * buttons.length), 1);
|
112
20
|
** board.appendChild(button[0]);**
|
113
21
|
if (buttons.length % size === 0) {
|
114
22
|
board.appendChild(document.createElement("br"));
|
115
|
-
|
23
|
+
|
116
|
-
}
|
117
|
-
}
|
118
|
-
})();
|
119
|
-
</script>
|
120
|
-
</body>
|
121
|
-
</html>
|
122
24
|
|
123
|
-
|
124
25
|
###試したこと
|
125
26
|
課題に対してアプローチしたことを記載してください
|
27
|
+
ご指摘いただいた通り、board.appendChild(button[0]);→board.appendChild(buttons[0]);へ変更してみましたが、まだ反映されないです。
|
126
28
|
|
127
29
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
128
30
|
より詳細な情報
|