Share
ShareSidebar
2011-10-12 00:10:51 +0

How to Check or Uncheck all checkboxes in JQuery

How to Check or Uncheck all checkboxes in JQuery?

Rate this post

You must be registered to vote first

Comments

jzentt
jzentt 2011-10-12 01:32:52

Checkbox

 <input type="checkbox" class="check" value="A"> Value A
 
<input type="checkbox" class="check" value="B"> Value B
 
<input type="checkbox" class="check" value="C"> Value C
 
<input type="checkbox" class="check" value="D"> Value D

Buttons

 Select: <input type="button" id="all" value="All"> <input type="button" id="none" value="None">

Jquery

<script type="text/javascript">
   $
(document).ready(function(){
      $
("#all").click(function() {
         $
(".check").attr('checked', true);
     
});
      $
("#none").click(function() {
         $
(".check").attr('checked', false);
     
});
   
});
 
</script>
+0

Comment