回答編集履歴

1

addEventListener -> stop を追加

2020/05/09 02:15

投稿

think49
think49

スコア18166

test CHANGED
@@ -128,7 +128,7 @@
128
128
 
129
129
  <input type="button" value="開始" style="position:absolute;left:50px;top:20px" />
130
130
 
131
- <input type="button" value="停止" onClick="stop()" style="position:absolute;left:90px;top:20px" />
131
+ <input type="button" value="停止" style="position:absolute;left:90px;top:20px" />
132
132
 
133
133
  <img id="myimg" src="number.gif" style="position:absolute;left:50px;top:50px;clip:rect(0px,60px,60px,0px)" />
134
134
 
@@ -140,7 +140,7 @@
140
140
 
141
141
 
142
142
 
143
- function stop()
143
+ function stop(event)
144
144
 
145
145
  {
146
146
 
@@ -190,12 +190,18 @@
190
190
 
191
191
  document.querySelector('input[type=button][value="開始"]').addEventListener('click', function (event){
192
192
 
193
- setInterval(scroll, 100);
193
+ TimeId = setInterval(scroll, 100);
194
194
 
195
195
  }, false);
196
196
 
197
+
198
+
199
+ document.querySelector('input[type=button][value="停止"]').addEventListener('click', stop, false);
200
+
197
201
  </script>
198
202
 
203
+
204
+
199
205
  ```
200
206
 
201
207