回答編集履歴

9

追記

2018/09/07 00:45

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -90,24 +90,6 @@
90
90
 
91
91
 
92
92
 
93
- ※本当は各年度に'2017'、'2016'みたいにidを振って、
93
+ 提示ソースでこんな感じ。
94
94
 
95
- ```
96
-
97
- var active = $('#active_id').get(0).value
98
-
99
- var current = $(this).get(0).id
100
-
101
- if ( active != "" ) {
102
-
103
- $('#Box' + active).display = "none";
95
+ [codepen](https://codepen.io/yukihisa/pen/dqVQZj)
104
-
105
- }
106
-
107
- $('#Box' + current).display = "";
108
-
109
- active = current;
110
-
111
- ```
112
-
113
- にしたい。。。

8

微修正

2018/09/07 00:45

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -100,11 +100,11 @@
100
100
 
101
101
  if ( active != "" ) {
102
102
 
103
- $('#Box' + active).style.display = "none";
103
+ $('#Box' + active).display = "none";
104
104
 
105
105
  }
106
106
 
107
- $('#Box' + current).style.display = "";
107
+ $('#Box' + current).display = "";
108
108
 
109
109
  active = current;
110
110
 

7

微修正

2018/09/07 00:23

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -94,7 +94,7 @@
94
94
 
95
95
  ```
96
96
 
97
- var active = $('active_id').get(0).value
97
+ var active = $('#active_id').get(0).value
98
98
 
99
99
  var current = $(this).get(0).id
100
100
 

6

誤字の修正

2018/09/07 00:15

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -100,11 +100,11 @@
100
100
 
101
101
  if ( active != "" ) {
102
102
 
103
- $('#BOX' + active).style.display = "none";
103
+ $('#Box' + active).style.display = "none";
104
104
 
105
105
  }
106
106
 
107
- $('#BOX' + current).style.display = "";
107
+ $('#Box' + current).style.display = "";
108
108
 
109
109
  active = current;
110
110
 

5

修正

2018/09/06 09:27

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -96,7 +96,7 @@
96
96
 
97
97
  var active = $('active_id').get(0).value
98
98
 
99
- var current = $(this).id
99
+ var current = $(this).get(0).id
100
100
 
101
101
  if ( active != "" ) {
102
102
 

4

微修正

2018/09/06 09:26

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -100,13 +100,13 @@
100
100
 
101
101
  if ( active != "" ) {
102
102
 
103
- $('#' + active).style.display = "none";
103
+ $('#BOX' + active).style.display = "none";
104
104
 
105
105
  }
106
106
 
107
107
  $('#BOX' + current).style.display = "";
108
108
 
109
- active = 'BOX' + current;
109
+ active = current;
110
110
 
111
111
  ```
112
112
 

3

誤字の修正

2018/09/06 09:14

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -106,7 +106,7 @@
106
106
 
107
107
  $('#BOX' + current).style.display = "";
108
108
 
109
- active = 'BOX' + id;
109
+ active = 'BOX' + current;
110
110
 
111
111
  ```
112
112
 

2

修正

2018/09/06 09:13

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -94,7 +94,7 @@
94
94
 
95
95
  ```
96
96
 
97
- var active = $('activeid').get(0).value
97
+ var active = $('active_id').get(0).value
98
98
 
99
99
  var current = $(this).id
100
100
 

1

追記

2018/09/06 09:11

投稿

yukihisa
yukihisa

スコア672

test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  //2017年表示
26
26
 
27
- if (active.value != null) {
27
+ if (active.value != "") {
28
28
 
29
29
  document.getElementById(active.value).style.display = "none";
30
30
 
@@ -40,7 +40,7 @@
40
40
 
41
41
  //2016年表示
42
42
 
43
- if (active.value != null) {
43
+ if (active.value != "") {
44
44
 
45
45
  document.getElementById(active.value).style.display = "none";
46
46
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  //2015年表示
58
58
 
59
- if (active.value != null) {
59
+ if (active.value != "") {
60
60
 
61
61
  document.getElementById(active.value).style.display = "none";
62
62
 
@@ -72,7 +72,7 @@
72
72
 
73
73
  //2014年表示
74
74
 
75
- if (active.value != null) {
75
+ if (active.value != "") {
76
76
 
77
77
  document.getElementById(active.value).style.display = "none";
78
78
 
@@ -87,3 +87,27 @@
87
87
  ```
88
88
 
89
89
  とりあえず適当ですがこんな感じ。
90
+
91
+
92
+
93
+ ※本当は各年度に'2017'、'2016'みたいにidを振って、
94
+
95
+ ```
96
+
97
+ var active = $('activeid').get(0).value
98
+
99
+ var current = $(this).id
100
+
101
+ if ( active != "" ) {
102
+
103
+ $('#' + active).style.display = "none";
104
+
105
+ }
106
+
107
+ $('#BOX' + current).style.display = "";
108
+
109
+ active = 'BOX' + id;
110
+
111
+ ```
112
+
113
+ にしたい。。。