CHECKBOX: Toggle All Checkboxes Via Class

Miva Knowledge Base
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.
Important Notice: This information is for internal reference only. Use at your own risk.

CHECKBOX: Toggle All Checkboxes Via Class

Scot Ranney • February 06, 2025


Requirements: Jquery

Controller Checkbox:

<input type="checkbox" class="check-all">

Checkbox List:

<input type="checkbox" class="auto-check" name="some_name_1" value="{ l.some_val_1 }">
<input type="checkbox" class="auto-check" name="some_name_2" value="{ l.some_val_2 }">
<input type="checkbox" class="auto-check" name="some_name_3" value="{ l.some_val_3 }">

Jquery Script:

<script>
$(".check-all").click(function(){
	$('.auto-check').not(this).prop('checked', this.checked);
});
</script>

https://www.scotsscripts.com/mvblog/checkbox-toggle-all-checkboxes-via-class.html

mvkb_checkbox mvkb_jquery