"Pin" a class to the selected radio button?

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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准