Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save konfuzius/0e5a001d8db0875cb28ca1ba4d41726b to your computer and use it in GitHub Desktop.

Select an option

Save konfuzius/0e5a001d8db0875cb28ca1ba4d41726b to your computer and use it in GitHub Desktop.
jQuery: Add/remove a class to labels with checkboxes and radio buttons and style them
//Add/remove a class to labels with checkboxes and radio buttons and style them
$('label input[type=radio], label input[type=checkbox]').click(function() {
$('label:has(input:checked)').addClass('active');
$('label:has(input:not(:checked))').removeClass('active');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment