Skip to content

Instantly share code, notes, and snippets.

@carlitoescobar
Created February 7, 2015 00:00
Show Gist options
  • Save carlitoescobar/c5172a5056c71b0becb4 to your computer and use it in GitHub Desktop.
Save carlitoescobar/c5172a5056c71b0becb4 to your computer and use it in GitHub Desktop.
Gravity Forms check all function (jQuery)
// Needed this for a client project, thanks! I improved upon it to make it more generic so you don't have to look up individual IDs on elements:
jQuery(document).ready(function(){
// Check all in Gravity Forms
jQuery('.checkall li:first-child input').click(function() {
jQuery(this).parent('li').parent('ul').find(':checkbox').attr('checked', this.checked);
});
});
// Just add a class "checkall" to your checkbox form item in Gravity Forms, it assumes the first item in the list will be the "All" option.
@ThePJDK
Copy link

ThePJDK commented Mar 15, 2017

Hi Carlito,
I am very much interested in using this function in a Gravity Forms form.

I just don't know how to implement this in WordPress/Gravity Forms.

Does it go into the functions.php?

Can it be used as a check/un-check all function?

Cheers

ThePJ

@Breklin
Copy link

Breklin commented Apr 25, 2018

It should go in the footer.php file, just before the closing tag. Make sure you wrap this in <script> tags.

@esoileme
Copy link

Thank you for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment