Add css class to selected radio labels


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(document).ready(function(){
  2. updateRadioLabels()
  3. $('input[type=radio]').change(updateRadioLabels)
  4. })
  5.  
  6. function updateRadioLabels(){
  7.  
  8. $('input[type=radio]').each(function(){
  9. $('input[name=' + this.name +'] + label').removeClass('selected');
  10. $('input[name=' + this.name +']:checked + label').addClass('selected');
  11. })
  12.  
  13. }

URL: add_css_class_to_selected_radio_labels

Report this snippet


Comments


You need to login to view comments.