回答編集履歴
1
補足の追加。
test
CHANGED
@@ -43,3 +43,35 @@
|
|
43
43
|
【jQueryで全選択・全解除はprop使う - Qiita】
|
44
44
|
|
45
45
|
[http://qiita.com/ituki_b/items/17eab8c38a2ad5392660](http://qiita.com/ituki_b/items/17eab8c38a2ad5392660)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
---
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
**追記:**
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
少し改良。
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```JavaScript
|
62
|
+
|
63
|
+
$( _=> {
|
64
|
+
|
65
|
+
const $_btn = $( '#btn' ), $_check = $( '[id^="check"]' ).prop( 'checked', false );
|
66
|
+
|
67
|
+
$_check.on( 'change', _=> {
|
68
|
+
|
69
|
+
const ck = $_check.length === $_check.filter( ':checked' ).length;
|
70
|
+
|
71
|
+
$_btn.prop( 'disabled', !ck )[ ck ? 'removeClass' : 'addClass' ]( 'inactive' );
|
72
|
+
|
73
|
+
} ).change();
|
74
|
+
|
75
|
+
} );
|
76
|
+
|
77
|
+
```**動くサンプル:**[https://jsfiddle.net/j5w2atvb/1/](https://jsfiddle.net/j5w2atvb/1/)
|