Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <form>
- <p><input type="checkbox" name="option[]" class="selectAll"> Select All</p>
- <p><input type="checkbox" name="option[]" class="option"> Option 1</p>
- <p><input type="checkbox" name="option[]" class="option"> Option 2</p>
- <p><input type="checkbox" name="option[]" class="option"> Option 3</p>
- <button type="submit">Submit</button>
- </form>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
- <script>
- // event handler for when an item with the 'selectAll' is changed
- $(".selectAll").change(function(){
- // set the 'checked' property of items with the 'option' class
- // to have the same value as the 'selectAll' checkbox
- $(".option").prop('checked', $(this).prop("checked"));
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement