Created
October 5, 2021 10:59
-
-
Save IgorGavrilenko/0afdcd139a79792f63837956d93a24b8 to your computer and use it in GitHub Desktop.
группа чекбоксов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class=""> | |
<label class="form-label"> | |
<input class="jq-check-all" type="checkbox" data-id="sort"> | |
<span class="form-label__capt">Все</span> | |
</label> | |
<label class="form-label"> | |
<input class="jq-check-rest" type="checkbox" data-id="sort"> | |
<span class="form-label__capt"></span> | |
</label> | |
</div> | |
<script> | |
$(document).ready(function() { | |
$(".jq-check-all").on("change", function() { | |
var groupId = $(this).data('id'); | |
$('.jq-check-rest[data-id="' + groupId + '"]').prop("checked", this.checked); | |
}); | |
$(".jq-check-rest").on("change", function() { | |
var groupId = $(this).data('id'); | |
var allChecked = $('.jq-check-rest[data-id="' + groupId + '"]:not(:checked)').length == 0; | |
$('.jq-check-all[data-id="' + groupId + '"]').prop("checked", allChecked); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment