回答編集履歴
1
sample
answer
CHANGED
@@ -4,4 +4,21 @@
|
|
4
4
|
|
5
5
|
> var checkAll = '#checkAll'
|
6
6
|
|
7
|
-
の整合性があってません
|
7
|
+
の整合性があってません
|
8
|
+
|
9
|
+
# sample
|
10
|
+
```javascript
|
11
|
+
$(function(){
|
12
|
+
var checkAll = '#checkALL';
|
13
|
+
var checkBox = 'input[name="goods[]"]';
|
14
|
+
$( checkAll ).on('change', function() {
|
15
|
+
$( checkBox ).prop('checked', $(this).prop('checked'));
|
16
|
+
});
|
17
|
+
$( checkBox ).on( 'change', function() {
|
18
|
+
$( checkAll ).prop( 'checked', $( checkBox ).not(':checked').length==0 );
|
19
|
+
/* もしくは
|
20
|
+
$( checkAll ).prop( 'checked', !$( checkBox ).is(':not(:checked)'));
|
21
|
+
*/
|
22
|
+
});
|
23
|
+
});
|
24
|
+
```
|