Last active
April 26, 2023 01:31
-
-
Save ricardozea/4686072 to your computer and use it in GitHub Desktop.
jQuery: Add/remove a class to labels with checkboxes and radio buttons and style them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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
👍🏽🙏🏽