Home  >  Article  >  Web Front-end  >  jQuery method to switch the selected state of all check boxes_jquery

jQuery method to switch the selected state of all check boxes_jquery

WBOY
WBOYOriginal
2016-05-16 15:51:501237browse

The example in this article describes how jQuery switches the selected state of all check boxes. Share it with everyone for your reference. The details are as follows:

This code is very simple and practical. It switches whether all checkboxes are selected through links

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 will be helpful to everyone’s jquery programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn