Forked from ricardozea/add-remove-class-to-labels.js
Created
January 10, 2023 18:59
-
-
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
This file contains hidden or 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