Skip to content

Instantly share code, notes, and snippets.

@fazlurr
Forked from jhned/radio-swap
Created June 22, 2014 13:47
Show Gist options
  • Select an option

  • Save fazlurr/34f0acaa0036907fa254 to your computer and use it in GitHub Desktop.

Select an option

Save fazlurr/34f0acaa0036907fa254 to your computer and use it in GitHub Desktop.
Give the label of a radio button a checked class when the input changes.
jQuery(function($) {
$(':radio').change(function () {
// First, clear out all radio buttons
$(':radio[name=' + this.name + ']').parent().removeClass('checked');
// Add the checked class to the parent. (probably a label)
$(this).parent().addClass('checked');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment