チェックボックスをicheckプラグインで設計し、次のように1つまたは複数のチェックボックス(すべてチェック)を操作しました:
HTML :
<div>Using Check all function</div>
<div id="action" class="action-class" style="display:none">SHOW ME</div>
<div id="selectCheckBox">
<input type="checkbox" class="all" />Select All
<input type="checkbox" class="check" />Check Box 1
<input type="checkbox" class="check" />Check Box 2
<input type="checkbox" class="check" />Check Box 3
<input type="checkbox" class="check" />Check Box 4
</div>
JS:
$(function () {
var checkAll = $('input.all');
var checkboxes = $('input.check');
$('input').iCheck();
checkAll.on('ifChecked ifUnchecked', function(event) {
if (event.type == 'ifChecked') {
checkboxes.iCheck('check');
} else {
checkboxes.iCheck('uncheck');
}
});
checkboxes.on('ifChanged', function(event){
if(checkboxes.filter(':checked').length == checkboxes.length) {
checkAll.prop('checked', 'checked');
} else {
checkAll.removeProp('checked');
}
checkAll.iCheck('update');
});
});
と が<div id="action" class="action-class" style="display:none">SHOW ME</div>
ありdisplay:none
ます。
ここで、チェックボックス (すべてと 1 つ) の入力がチェックされているdiv
かどうかを表示する必要があります。
これどうやって見せればいいの!?
デモJSFIDDLE