I’m trying to add a class to the selected radio input and then remove that class when another radio of the same type is selected
The radio buttons have the class ‘radio_button’ but i can’t get the class to change with the below code.
jQuery('.radio_button').livequery('click',function() { $('input.radio_button :radio').focus(updateSelectedStyle); $('input.radio_button :radio').blur(updateSelectedStyle); $('input.radio_button :radio').change(updateSelectedStyle); } function updateSelectedStyle() { $('input.radio_button :radio').removeClass('focused'); $('input.radio_button :radio:checked').addClass('focused'); }
Tre problem is caused by one extra space in your selectors.
Instead of:
you wanted to write: