質問編集履歴
1
コードの入力を正しくしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,52 @@
|
|
1
|
+
```Javascript
|
2
|
+
|
3
|
+
<!DOCTYPE html>
|
4
|
+
|
5
|
+
<html>
|
6
|
+
|
7
|
+
<head>
|
8
|
+
|
9
|
+
<meta charset="UTF-8" />
|
10
|
+
|
11
|
+
<title>サンプル</title>
|
12
|
+
|
1
|
-
|
13
|
+
</head>
|
14
|
+
|
2
|
-
|
15
|
+
<body>
|
16
|
+
|
3
|
-
|
17
|
+
<h1 id="kakikae">0回目</h1>
|
18
|
+
|
19
|
+
<input id="start" type="button" value="start">
|
20
|
+
|
21
|
+
<script>
|
22
|
+
|
23
|
+
window.onload = function(){
|
24
|
+
|
25
|
+
document.getElementById("start").addEventListener("click",function()
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
var times =0;
|
30
|
+
|
31
|
+
var timeselement =document.getElementById("kakikae") ;
|
32
|
+
|
33
|
+
for(var times=0;times<10;times++){
|
34
|
+
|
35
|
+
alert();
|
36
|
+
|
37
|
+
timeselement.textContent = times +1+ "回目";}
|
38
|
+
|
39
|
+
} )
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
</script>
|
44
|
+
|
45
|
+
</body>
|
46
|
+
|
47
|
+
</html>
|
48
|
+
|
49
|
+
```
|
4
50
|
|
5
51
|
### 前提・実現したいこと
|
6
52
|
|
@@ -18,7 +64,9 @@
|
|
18
64
|
|
19
65
|
|
20
66
|
|
21
|
-
### 該当のソースコード
|
67
|
+
### 該当のソースコード
|
68
|
+
|
69
|
+
```html
|
22
70
|
|
23
71
|
<!DOCTYPE html>
|
24
72
|
|
@@ -36,6 +84,62 @@
|
|
36
84
|
|
37
85
|
<h1 id="kakikae">0回目</h1>
|
38
86
|
|
87
|
+
<input id="start" type="button" value="start">
|
88
|
+
|
89
|
+
<script>
|
90
|
+
|
91
|
+
window.onload = function(){
|
92
|
+
|
93
|
+
document.getElementById("start").addEventListener("click",function()
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
var times =0;
|
98
|
+
|
99
|
+
var timeselement =document.getElementById("kakikae") ;
|
100
|
+
|
101
|
+
for(var times=0;times<10;times++){
|
102
|
+
|
103
|
+
alert();
|
104
|
+
|
105
|
+
timeselement.textContent = times +1+ "回目";}
|
106
|
+
|
107
|
+
} )
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
</script>
|
112
|
+
|
113
|
+
</body>
|
114
|
+
|
115
|
+
</html>
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
### 試したこと
|
122
|
+
|
123
|
+
下記のようにfor文を外してみましたが同様の動作です(最後だけ数字が変わる)。
|
124
|
+
|
125
|
+
```html
|
126
|
+
|
127
|
+
<!DOCTYPE html>
|
128
|
+
|
129
|
+
<html>
|
130
|
+
|
131
|
+
<head>
|
132
|
+
|
133
|
+
<meta charset="UTF-8" />
|
134
|
+
|
135
|
+
<title>サンプル</title>
|
136
|
+
|
137
|
+
</head>
|
138
|
+
|
139
|
+
<body>
|
140
|
+
|
141
|
+
<h1 id="kakikae">0回目</h1>
|
142
|
+
|
39
143
|
<input id="start" type="button" value="start">
|
40
144
|
|
41
145
|
<script>
|
@@ -46,11 +150,37 @@
|
|
46
150
|
|
47
151
|
var times =0;
|
48
152
|
|
49
|
-
var timeselement =document.getElementById("kakikae") ;
|
153
|
+
var timeselement =document.getElementById("kakikae") ;
|
50
|
-
|
154
|
+
|
51
|
-
|
155
|
+
alert();
|
52
|
-
|
156
|
+
|
53
|
-
|
157
|
+
timeselement.textContent = times +1+ "回目";
|
158
|
+
|
159
|
+
times =times +1;
|
160
|
+
|
161
|
+
alert();
|
162
|
+
|
163
|
+
timeselement.textContent = times +1+ "回目";
|
164
|
+
|
165
|
+
times =times +1;
|
166
|
+
|
167
|
+
alert();
|
168
|
+
|
169
|
+
timeselement.textContent = times +1+ "回目";
|
170
|
+
|
171
|
+
times =times +1;
|
172
|
+
|
173
|
+
alert();
|
174
|
+
|
175
|
+
timeselement.textContent = times +1+ "回目";
|
176
|
+
|
177
|
+
times =times +1;
|
178
|
+
|
179
|
+
alert();
|
180
|
+
|
181
|
+
timeselement.textContent = times +1+ "回目";
|
182
|
+
|
183
|
+
|
54
184
|
|
55
185
|
})
|
56
186
|
|
@@ -64,79 +194,7 @@
|
|
64
194
|
|
65
195
|
|
66
196
|
|
67
|
-
### 試したこと
|
68
|
-
|
69
|
-
下記のようにfor文を外してみましたが同様の動作です(最後だけ数字が変わる)。
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<!DOCTYPE html>
|
74
|
-
|
75
|
-
<html>
|
76
|
-
|
77
|
-
<head>
|
78
|
-
|
79
|
-
<meta charset="UTF-8" />
|
80
|
-
|
81
|
-
<title>サンプル</title>
|
82
|
-
|
83
|
-
</head>
|
84
|
-
|
85
|
-
<body>
|
86
|
-
|
87
|
-
<h1 id="kakikae">0回目</h1>
|
88
|
-
|
89
|
-
<input id="start" type="button" value="start">
|
90
|
-
|
91
|
-
<script>
|
92
|
-
|
93
|
-
window.onload = function(){
|
94
|
-
|
95
|
-
document.getElementById("start").addEventListener("click",function(){
|
96
|
-
|
97
|
-
var times =0;
|
98
|
-
|
99
|
-
var timeselement =document.getElementById("kakikae") ;
|
100
|
-
|
101
|
-
alert();
|
102
|
-
|
103
|
-
timeselement.textContent = times +1+ "回目";
|
104
|
-
|
105
|
-
times =times +1;
|
106
|
-
|
107
|
-
alert();
|
108
|
-
|
109
|
-
timeselement.textContent = times +1+ "回目";
|
110
|
-
|
111
|
-
times =times +1;
|
112
|
-
|
113
|
-
alert();
|
114
|
-
|
115
|
-
timeselement.textContent = times +1+ "回目";
|
116
|
-
|
117
|
-
times =times +1;
|
118
|
-
|
119
|
-
alert();
|
120
|
-
|
121
|
-
timeselement.textContent = times +1+ "回目";
|
122
|
-
|
123
|
-
times =times +1;
|
124
|
-
|
125
|
-
alert();
|
126
|
-
|
127
|
-
timeselement.textContent = times +1+ "回目";
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
197
|
+
```
|
132
|
-
|
133
|
-
}
|
134
|
-
|
135
|
-
</script>
|
136
|
-
|
137
|
-
</body>
|
138
|
-
|
139
|
-
</html>
|
140
198
|
|
141
199
|
|
142
200
|
|