Skip to content

Instantly share code, notes, and snippets.

@konfuzius
konfuzius / add-remove-class-to-labels.js
Created January 10, 2023 18:59 — forked from ricardozea/add-remove-class-to-labels.js
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');
});