回答編集履歴

2

調整

2022/06/29 00:46

投稿

yambejp
yambejp

スコア114878

test CHANGED
@@ -1,14 +1,20 @@
1
1
  ```javascript
2
2
  <script>
3
- let timerID;
4
3
  window.addEventListener('DOMContentLoaded', ()=>{
4
+ let timerID;
5
+ const myfunc=()=>{
6
+ console.log('事前に用意しておいた関数');
7
+ };
5
8
  b1.addEventListener('click',()=>{
6
9
  d1.showModal();
7
- clearTimeout(timerID);
8
- timerID=setTimeout(()=>d1.close(),10000);
10
+ timerID=setTimeout(()=>{
11
+ d1.close();
12
+ myfunc();
13
+ },2000);
9
14
  });
10
15
  b2.addEventListener('click',()=>{
11
16
  d1.close();
17
+ clearTimeout(timerID);
12
18
  });
13
19
  });
14
20
  </script>
@@ -16,4 +22,5 @@
16
22
  <input type="button" value="ok" id="b2">
17
23
  </dialog>
18
24
  <input type="button" value="open dialog" id="b1">
25
+
19
26
  ```

1

chousei

2022/06/29 00:42

投稿

yambejp
yambejp

スコア114878

test CHANGED
@@ -4,11 +4,11 @@
4
4
  window.addEventListener('DOMContentLoaded', ()=>{
5
5
  b1.addEventListener('click',()=>{
6
6
  d1.showModal();
7
+ clearTimeout(timerID);
7
8
  timerID=setTimeout(()=>d1.close(),10000);
8
9
  });
9
10
  b2.addEventListener('click',()=>{
10
11
  d1.close();
11
- clearTimeout(timerID);
12
12
  });
13
13
  });
14
14
  </script>