Class Match Radio Button

Published on

This is just a very simple code snippet that I often find myself writing. It uses jQuery, when a radio button is selected it adds a class to its label and removes the class from the other labels that are within the group (name). I tend to use classes as selectors, but this version is more generic.


    function changeTab() {
     var e = $(this)[0];
     $.each($('[name="' + + '"]'), function(i,e) {
     $('[for="' + + '"]').removeClass('active');
     $('label[for="' + + '"]').addClass('active');