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');
}
Nice question, because I learned about the livequery plugin. BTW, your code example has one brace ")" missing.
以上就是"Pin" a class to the selected radio button?的详细内容,更多请关注web前端其它相关文章!