Check/Uncheck checkbox group

<script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script> <input type="button" class="check" value="check all" /> </br> <input type="checkbox" class="cb-element" /> Checkbox 1</br> <input type="checkbox" class="cb-element" /> Checkbox 2</br> <input type="checkbox" class="cb-element" /> Checkbox 3</br> <script> $(document).ready(function(){ $('.check:button').toggle(function(){ $('input:checkbox').attr('checked','checked'); $(this).val('uncheck all') },function(){ $('input:checkbox').removeAttr('checked'); $(this).val('check all'); }) }) </script>

Share This: