jQuery toggles the selected state of all check boxes

  • 2020-06-22 23:51:29
  • OfStack

This article illustrated how jQuery toggles the selected state of all check boxes. Share to everybody for everybody reference. The details are as follows:

This code is very simple and practical and toggles whether all checkbox is selected by linking


var tog = false;
// or true if they are checked on load 
 $('a').click(function() { 
  $("input[type=checkbox]").attr("checked",!tog); 
 tog = !tog; 
 });

I hope this article has been helpful for your jquery programming.


Related articles: