質問編集履歴

3

誤字修正

2020/07/26 08:14

投稿

06140614
06140614

スコア2

title CHANGED
File without changes
body CHANGED
@@ -47,24 +47,6 @@
47
47
       // 処理内容↑↑↑
48
48
  }, 500 ) ;
49
49
  } ) ;
50
- // 処理内容↓↓↓
51
- window.addEventListener('DOMContentLoaded',function(){
52
- const target={tab1:"first",tab2:"second",tab3:"third",tab4:"four"};
53
- [].forEach.call(document.querySelectorAll('.tab'),function(x){
54
- x.addEventListener('click',function(e){
55
- const slideClass=document.querySelector('#slide').classList;
56
- [].forEach.call(slideClass,function(x){
57
- slideClass.remove(x);
58
- });
59
- slideClass.add("move-to-"+target[x.id]);
60
- document.querySelector('.tab.selected').classList.remove('selected');
61
- x.classList.add('selected');
62
- });
63
- });
64
- });
65
-      // 処理内容↑↑↑
66
- }, 500 ) ;
67
- } ) ;
68
50
  ```
69
51
 
70
52
 

2

リンクURL修正

2020/07/26 08:14

投稿

06140614
06140614

スコア2

title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
  ```
23
23
 
24
24
  【resizeイベント導入後 -- jsが動きません↓】
25
- resizeイベントは[こちら](https://lab.syncer.jp/Web/JavaScript/Snippet/74/)のサイトを参考させていただきました。
25
+ resizeイベントは[こちら](https://lab.syncer.jp/Web/JavaScript/Snippet/71/)のサイトを参考させていただきました。
26
26
  ```JavaScript
27
27
  var timeoutId ;
28
28
  window.addEventListener( "resize", function () {

1

resizeイベントの記述変更

2020/07/26 08:13

投稿

06140614
06140614

スコア2

title CHANGED
File without changes
body CHANGED
@@ -26,8 +26,27 @@
26
26
  ```JavaScript
27
27
  var timeoutId ;
28
28
  window.addEventListener( "resize", function () {
29
- clearTimeout( timeoutId ) ;
29
+ if ( timeoutId ) return ;
30
30
  timeoutId = setTimeout( function () {
31
+ timeoutId = 0 ;
32
+ // 処理内容↓↓↓
33
+ window.addEventListener('DOMContentLoaded',function(){
34
+ const target={tab1:"first",tab2:"second",tab3:"third",tab4:"four"};
35
+ [].forEach.call(document.querySelectorAll('.tab'),function(x){
36
+ x.addEventListener('click',function(e){
37
+ const slideClass=document.querySelector('#slide').classList;
38
+ [].forEach.call(slideClass,function(x){
39
+ slideClass.remove(x);
40
+ });
41
+ slideClass.add("move-to-"+target[x.id]);
42
+ document.querySelector('.tab.selected').classList.remove('selected');
43
+ x.classList.add('selected');
44
+ });
45
+ });
46
+ });
47
+      // 処理内容↑↑↑
48
+ }, 500 ) ;
49
+ } ) ;
31
50
  // 処理内容↓↓↓
32
51
  window.addEventListener('DOMContentLoaded',function(){
33
52
  const target={tab1:"first",tab2:"second",tab3:"third",tab4:"four"};