Posted By

ping_ch on 08/06/09


Tagged

html jquery radio labels radiobutton


Versions (?)

Add css class to selected radio labels


 / Published in: jQuery
 

URL: add_css_class_to_selected_radio_labels

  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. }

Report this snippet  

You need to login to post a comment.