質問編集履歴
1
コード追加しました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,176 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
<!DOCTYPE html>
|
4
|
+
|
5
|
+
<html lang="ja">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
|
9
|
+
<meta charset ="UTF-8">
|
10
|
+
|
11
|
+
<title>ルーレット</title>
|
12
|
+
|
13
|
+
<link rel = "stylesheet" href = "roulette.css">
|
14
|
+
|
15
|
+
<script src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
|
16
|
+
|
17
|
+
<script>
|
18
|
+
|
19
|
+
var roulette_id;
|
20
|
+
|
21
|
+
var start_flag = false;
|
22
|
+
|
23
|
+
var cell = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
|
24
|
+
|
25
|
+
var num =1;
|
26
|
+
|
27
|
+
var random;
|
28
|
+
|
29
|
+
function random_start() {
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
if ( start_flag === false) {
|
34
|
+
|
35
|
+
roulette_id = setInterval(roulette_start, 100);
|
36
|
+
|
37
|
+
start_flag =true;
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
function roulette_start() {
|
48
|
+
|
49
|
+
$('#td' + num).css('backgroundColor', 'white');
|
50
|
+
|
51
|
+
random = Math.floor(Math.random() * cell.length);
|
52
|
+
|
53
|
+
num = cell[random];
|
54
|
+
|
55
|
+
$('#td' + num).css('backgroundColor', 'red');
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
function random_stop() {
|
62
|
+
|
63
|
+
clearInterval(roulette_id);
|
64
|
+
|
65
|
+
start_flag = false;
|
66
|
+
|
67
|
+
$('#td' + num).css('backgroundColor', 'blue');
|
68
|
+
|
69
|
+
cell.splice(random, 1);
|
70
|
+
|
71
|
+
num=0;
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
function random_reset() {
|
78
|
+
|
79
|
+
start_flag =false;
|
80
|
+
|
81
|
+
clearInterval(roulette_id);
|
82
|
+
|
83
|
+
cell = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
|
84
|
+
|
85
|
+
$("td").css('backgroundColor', 'white');
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
$(function() {
|
92
|
+
|
93
|
+
$('#start').click(random_start);
|
94
|
+
|
95
|
+
$('#stop').click(random_stop);
|
96
|
+
|
97
|
+
$('#reset').click(random_reset);
|
98
|
+
|
99
|
+
});
|
100
|
+
|
101
|
+
</script>
|
102
|
+
|
103
|
+
</head>
|
104
|
+
|
105
|
+
<body>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<table>
|
110
|
+
|
111
|
+
<tr>
|
112
|
+
|
113
|
+
<td id="td1">1</td>
|
114
|
+
|
115
|
+
<td id="td2">2</td>
|
116
|
+
|
117
|
+
<td id="td3">3</td>
|
118
|
+
|
119
|
+
<td id="td4">4</td>
|
120
|
+
|
121
|
+
</tr>
|
122
|
+
|
123
|
+
<tr>
|
124
|
+
|
125
|
+
<td id="td5">5</td>
|
126
|
+
|
127
|
+
<td id="td6">6</td>
|
128
|
+
|
129
|
+
<td id="td7">7</td>
|
130
|
+
|
131
|
+
<td id="td8">8</td>
|
132
|
+
|
133
|
+
</tr>
|
134
|
+
|
135
|
+
<tr>
|
136
|
+
|
137
|
+
<td id="td9">9</td>
|
138
|
+
|
139
|
+
<td id="td10">10</td>
|
140
|
+
|
141
|
+
<td id="td11">11</td>
|
142
|
+
|
143
|
+
<td id="td12">12</td>
|
144
|
+
|
145
|
+
</tr>
|
146
|
+
|
147
|
+
<tr>
|
148
|
+
|
149
|
+
<td id="td13">13</td>
|
150
|
+
|
151
|
+
<td id="td14">14</td>
|
152
|
+
|
153
|
+
<td id="td15">15</td>
|
154
|
+
|
155
|
+
<td id="td16">16</td>
|
156
|
+
|
157
|
+
</tr>
|
158
|
+
|
159
|
+
</table>
|
160
|
+
|
161
|
+
<button id ="start">スタート</button>
|
162
|
+
|
163
|
+
<button id ="stop">ストップ</button>
|
164
|
+
|
165
|
+
<button id ="reset">リセット</button>
|
166
|
+
|
167
|
+
</body>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
</html>
|
172
|
+
|
1
|
-
### 前提・実現したいこと
|
173
|
+
```### 前提・実現したいこと
|
2
174
|
|
3
175
|
プログラミング初心者です。16桁の数字でルーレットを作っているのですが、
|
4
176
|
|
@@ -24,175 +196,7 @@
|
|
24
196
|
|
25
197
|
|
26
198
|
|
27
|
-
|
199
|
+
|
28
|
-
|
29
|
-
<html lang="ja">
|
30
|
-
|
31
|
-
<head>
|
32
|
-
|
33
|
-
<meta charset ="UTF-8">
|
34
|
-
|
35
|
-
<title>ルーレット</title>
|
36
|
-
|
37
|
-
<link rel = "stylesheet" href = "roulette.css">
|
38
|
-
|
39
|
-
<script src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
|
40
|
-
|
41
|
-
<script>
|
42
|
-
|
43
|
-
var roulette_id;
|
44
|
-
|
45
|
-
var start_flag = false;
|
46
|
-
|
47
|
-
var cell = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
|
48
|
-
|
49
|
-
var num =1;
|
50
|
-
|
51
|
-
var random;
|
52
|
-
|
53
|
-
function random_start() {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if ( start_flag === false) {
|
58
|
-
|
59
|
-
roulette_id = setInterval(roulette_start, 100);
|
60
|
-
|
61
|
-
start_flag =true;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
function roulette_start() {
|
72
|
-
|
73
|
-
$('#td' + num).css('backgroundColor', 'white');
|
74
|
-
|
75
|
-
random = Math.floor(Math.random() * cell.length);
|
76
|
-
|
77
|
-
num = cell[random];
|
78
|
-
|
79
|
-
$('#td' + num).css('backgroundColor', 'red');
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
function random_stop() {
|
86
|
-
|
87
|
-
clearInterval(roulette_id);
|
88
|
-
|
89
|
-
start_flag = false;
|
90
|
-
|
91
|
-
$('#td' + num).css('backgroundColor', 'blue');
|
92
|
-
|
93
|
-
cell.splice(random, 1);
|
94
|
-
|
95
|
-
num=0;
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
function random_reset() {
|
102
|
-
|
103
|
-
start_flag =false;
|
104
|
-
|
105
|
-
clearInterval(roulette_id);
|
106
|
-
|
107
|
-
cell = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
|
108
|
-
|
109
|
-
$("td").css('backgroundColor', 'white');
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
$(function() {
|
116
|
-
|
117
|
-
$('#start').click(random_start);
|
118
|
-
|
119
|
-
$('#stop').click(random_stop);
|
120
|
-
|
121
|
-
$('#reset').click(random_reset);
|
122
|
-
|
123
|
-
});
|
124
|
-
|
125
|
-
</script>
|
126
|
-
|
127
|
-
</head>
|
128
|
-
|
129
|
-
<body>
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
<table>
|
134
|
-
|
135
|
-
<tr>
|
136
|
-
|
137
|
-
<td id="td1">1</td>
|
138
|
-
|
139
|
-
<td id="td2">2</td>
|
140
|
-
|
141
|
-
<td id="td3">3</td>
|
142
|
-
|
143
|
-
<td id="td4">4</td>
|
144
|
-
|
145
|
-
</tr>
|
146
|
-
|
147
|
-
<tr>
|
148
|
-
|
149
|
-
<td id="td5">5</td>
|
150
|
-
|
151
|
-
<td id="td6">6</td>
|
152
|
-
|
153
|
-
<td id="td7">7</td>
|
154
|
-
|
155
|
-
<td id="td8">8</td>
|
156
|
-
|
157
|
-
</tr>
|
158
|
-
|
159
|
-
<tr>
|
160
|
-
|
161
|
-
<td id="td9">9</td>
|
162
|
-
|
163
|
-
<td id="td10">10</td>
|
164
|
-
|
165
|
-
<td id="td11">11</td>
|
166
|
-
|
167
|
-
<td id="td12">12</td>
|
168
|
-
|
169
|
-
</tr>
|
170
|
-
|
171
|
-
<tr>
|
172
|
-
|
173
|
-
<td id="td13">13</td>
|
174
|
-
|
175
|
-
<td id="td14">14</td>
|
176
|
-
|
177
|
-
<td id="td15">15</td>
|
178
|
-
|
179
|
-
<td id="td16">16</td>
|
180
|
-
|
181
|
-
</tr>
|
182
|
-
|
183
|
-
</table>
|
184
|
-
|
185
|
-
<button id ="start">スタート</button>
|
186
|
-
|
187
|
-
<button id ="stop">ストップ</button>
|
188
|
-
|
189
|
-
<button id ="reset">リセット</button>
|
190
|
-
|
191
|
-
</body>
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
</html>
|
196
200
|
|
197
201
|
### 試したこと
|
198
202
|
|