質問編集履歴

3

JavaScriptの修正

2016/07/13 05:19

投稿

ryosaku
ryosaku

スコア12

test CHANGED
File without changes
test CHANGED
@@ -172,7 +172,45 @@
172
172
 
173
173
  ```Javascript
174
174
 
175
- $(function() {
175
+ $(function (){
176
+
177
+ $('.s_color').on('click', function() {
178
+
179
+ if ($(this).prop('checked')){
180
+
181
+ $('.s_color').prop('checked', false);
182
+
183
+ $(this).prop('checked', true);
184
+
185
+ }
186
+
187
+ });
188
+
189
+ $('.s_type').on('click', function() {
190
+
191
+ if ($(this).prop('checked')){
192
+
193
+ $('.s_type').prop('checked', false);
194
+
195
+ $(this).prop('checked', true);
196
+
197
+ }
198
+
199
+ });
200
+
201
+ $('.s_taste').on('click', function() {
202
+
203
+ if ($(this).prop('checked')){
204
+
205
+ $('.s_taste').prop('checked', false);
206
+
207
+ $(this).prop('checked', true);
208
+
209
+ }
210
+
211
+ });
212
+
213
+
176
214
 
177
215
  var $chkbxFilter_all = $('#all');
178
216
 
@@ -192,13 +230,13 @@
192
230
 
193
231
  if($('#' + this).is(':checked')) {
194
232
 
195
- $("#search-box label" + ":not(." + this + ")").addClass('hidden-not-' + this);
233
+ $("#item_images_wrap " + $chkbxFilter_blocks + ":not(." + this + ")").addClass('hidden-not-' + this);
196
234
 
197
235
  $chkbxFilter_all.prop('checked',false).parent().removeClass("selected");
198
236
 
199
237
  } else if($('#' + this).not(':checked')) {
200
238
 
201
- $("#search-box label" + ":not(." + this + ")").removeClass('hidden-not-' + this);
239
+ $("#item_images_wrap " + $chkbxFilter_blocks + ":not(." + this + ")").removeClass('hidden-not-' + this);
202
240
 
203
241
  }
204
242
 
@@ -212,10 +250,14 @@
212
250
 
213
251
  };
214
252
 
253
+ hoge()
254
+
215
255
  });
216
256
 
217
257
  });
218
258
 
259
+
260
+
219
261
  ```
220
262
 
221
263
  ※javascriptは http://jsfiddle.net/kah601xq/11/ を参考にし、改変して使用しています。

2

参考URLの追加

2016/07/13 05:19

投稿

ryosaku
ryosaku

スコア12

test CHANGED
File without changes
test CHANGED
@@ -172,10 +172,6 @@
172
172
 
173
173
  ```Javascript
174
174
 
175
- ※参考にさせて貰ったサンプルがあるので、掲載に問題があるようでしたら削除します。
176
-
177
-
178
-
179
175
  $(function() {
180
176
 
181
177
  var $chkbxFilter_all = $('#all');
@@ -221,3 +217,5 @@
221
217
  });
222
218
 
223
219
  ```
220
+
221
+ ※javascriptは http://jsfiddle.net/kah601xq/11/ を参考にし、改変して使用しています。

1

htmlの追加

2016/07/13 05:09

投稿

ryosaku
ryosaku

スコア12

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,116 @@
20
20
 
21
21
  ```html
22
22
 
23
+ <script>
24
+
25
+ var $chkbxFilter_tags = ['red','yellow','green','vegetable','fruit','sweet','hot','sour'];
26
+
27
+ var $chkbxFilter_blocks = ['section']
28
+
29
+ </script>
30
+
31
+
32
+
33
+ <div id="search-box">
34
+
35
+ <div class="list-group">
36
+
37
+ <label class="list-group-item disabled">
38
+
39
+ <p class="list-group-item-text">色</p>
40
+
41
+ </label>
42
+
43
+ <label class="list-group-item">
44
+
45
+ <input type="checkbox" id="red" class="sort s_color">
46
+
47
+ <h4 class="list-group-item-heading">赤</h4>
48
+
49
+ </label>
50
+
51
+ <label class="list-group-item">
52
+
53
+ <input type="checkbox" id="yellow" class="sort s_color">
54
+
55
+ <h4 class="list-group-item-heading">黄</h4>
56
+
57
+ </label>
58
+
59
+ <label class="list-group-item">
60
+
61
+ <input type="checkbox" id="green" class="sort s_color">
62
+
63
+ <h4 class="list-group-item-heading">緑</h4>
64
+
65
+ </label>
66
+
67
+ </div>
68
+
69
+ <div class="list-group">
70
+
71
+ <label class="list-group-item disabled">
72
+
73
+ <p class="list-group-item-text">種類</p>
74
+
75
+ </label>
76
+
77
+ <label class="list-group-item">
78
+
79
+ <input type="checkbox" id="vegetable" class="sort s_type">
80
+
81
+ <h4 class="list-group-item-heading">野菜</h4>
82
+
83
+ </label>
84
+
85
+ <label class="list-group-item">
86
+
87
+ <input type="checkbox" id="fruit" class="sort s_type">
88
+
89
+ <h4 class="list-group-item-heading">果物</h4>
90
+
91
+ </label>
92
+
93
+ </div>
94
+
95
+ <div class="list-group">
96
+
97
+ <label class="list-group-item disabled">
98
+
99
+ <p class="list-group-item-text">味</p>
100
+
101
+ </label>
102
+
103
+ <label class="list-group-item">
104
+
105
+ <input type="checkbox" id="sweet" class="sort s_taste">
106
+
107
+ <h4 class="list-group-item-heading">甘い</h4>
108
+
109
+ </label>
110
+
111
+ <label class="list-group-item">
112
+
113
+ <input type="checkbox" id="hot" class="sort s_taste">
114
+
115
+ <h4 class="list-group-item-heading">辛い</h4>
116
+
117
+ </label>
118
+
119
+ <label class="list-group-item">
120
+
121
+ <input type="checkbox" id="sour" class="sort s_taste">
122
+
123
+ <h4 class="list-group-item-heading">酸っぱい</h4>
124
+
125
+ </label>
126
+
127
+ </div>
128
+
129
+ </div>
130
+
131
+
132
+
23
133
  <div id="item_images_wrap">
24
134
 
25
135
  <div class="about_sale_main"> 親要素