Advertisement
Guest User

Untitled

a guest
May 28th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <html>
  2.  
  3. <form>
  4. <p><input type="checkbox" name="option[]" class="selectAll"> Select All</p>
  5. <p><input type="checkbox" name="option[]" class="option"> Option 1</p>
  6. <p><input type="checkbox" name="option[]" class="option"> Option 2</p>
  7. <p><input type="checkbox" name="option[]" class="option"> Option 3</p>
  8.  
  9. <button type="submit">Submit</button>
  10. </form>
  11.  
  12. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
  13.  
  14. <script>
  15. // event handler for when an item with the 'selectAll' is changed
  16. $(".selectAll").change(function(){
  17. // set the 'checked' property of items with the 'option' class
  18. // to have the same value as the 'selectAll' checkbox
  19. $(".option").prop('checked', $(this).prop("checked"));
  20. });
  21. </script>
  22.  
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement