[jQuery] addClass and removeClass

[jQuery] addClass and removeClass


Hi there,
I'm getting an interesting problem with addClass and removeClass. I'm
attempting to build a rating system using radio buttons to select the
rating. I'm actually hiding my radio buttons and styling the label to
have pretty stars instead for a nicer interface. I want to highlight the
star when the radio button is selected, so when the label is clicked by
adding the 'active' class. I also need to remove the 'active' class from
all other labels so that only one is selected at any one time.
I assumed that removing the class from all of them and then re-adding
for the one I am clicking would be the most efficient way for doing this
like so.
jQuery(document).ready(function () {
jQuery('label.star').click(function (event) {
jQuery('label.star').removeClass('active');
jQuery(event.target).addClass('active');
});
});
However this now has no effect, the class is simply not added at all now.
Anyone got any ideas why this doesn't work?
Cheers
RobL
http://www.robl.me