Skip to content

Instantly share code, notes, and snippets.

@nihat-js
Created March 18, 2024 11:42
Show Gist options
  • Save nihat-js/3e74e92510cdd0d89da8104faddc73ae to your computer and use it in GitHub Desktop.
Save nihat-js/3e74e92510cdd0d89da8104faddc73ae to your computer and use it in GitHub Desktop.
select[all,none] jquery
$("#admin_basket_check_all").on("change",function(){
if ($(this).is(":checked")){
$("tbody [type='checkbox']").prop("checked",true)
}else{
$("tbody [type='checkbox']").prop("checked",false)
}
})
$(document).on("change","tbody [type='checkbox']",function(){
let isAllChecked = $("tbody input:checked").length === $("table tbody input:not(:checked)").length
$("#admin_basket_check_all").prop("checked", isAllChecked)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment