Home  >  Article  >  Web Front-end  >  jquery 实现的复选框全选与反选

jquery 实现的复选框全选与反选

WBOY
WBOYOriginal
2016-06-01 09:54:301047browse

此代码简单但适用。

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

需要的码农可以拿去实验一下,效果不错。

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