回答編集履歴
1
調整
test
CHANGED
@@ -35,3 +35,53 @@
|
|
35
35
|
</ul>
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
上記性質を活かすとこう
|
40
|
+
|
41
|
+
```javascript
|
42
|
+
|
43
|
+
<script>
|
44
|
+
|
45
|
+
$(function(){
|
46
|
+
|
47
|
+
$('button[data-group]').on('click',function(){
|
48
|
+
|
49
|
+
var group=$(this).data('group');
|
50
|
+
|
51
|
+
$('.line').hide().filter(function(){
|
52
|
+
|
53
|
+
return $.inArray(group,$(this).data('group'))>-1;
|
54
|
+
|
55
|
+
}).show();
|
56
|
+
|
57
|
+
});
|
58
|
+
|
59
|
+
});
|
60
|
+
|
61
|
+
</script>
|
62
|
+
|
63
|
+
<div class="buttonWrap">
|
64
|
+
|
65
|
+
<button data-group="red">赤</button>
|
66
|
+
|
67
|
+
<button data-group="yellow">黄色</button>
|
68
|
+
|
69
|
+
<button data-group="green">緑</button>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
<ul class="list">
|
74
|
+
|
75
|
+
<li class="line" data-group='["red","green"]'>商品1(rg)</li>
|
76
|
+
|
77
|
+
<li class="line" data-group='["red"]'>商品2(r)</li>
|
78
|
+
|
79
|
+
<li class="line" data-group='["yellow"]'>商品3(y)</li>
|
80
|
+
|
81
|
+
<li class="line" data-group='["red","green"]'>商品4(rg)</li>
|
82
|
+
|
83
|
+
<li class="line" data-group='["green"]'>商品5(g)</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
|
87
|
+
```
|