mus mus - 2 months ago 7
CSS Question

Highlight button when radio button is checked

I am trying to highlight a save button once one of three radio buttons are checked.

Then once the user clicks the save button, it should lose the highlight class and return to normal, the user can also click the cancel button and the save button will lose the highlight effect.

$('label').click(function() {
$('.greyBtn').addClass('glow');
if ($('.greyBtn').data('clicked', true)) {
$('greyBtn').removeClass('glow');
} else if ($('.cancel').data('clicked', true)) {
$('greyBtn').remove.Class('glow');
}
});


Right now it only highlights the save button upon radio button check, it will not lose the class again, when i click the buttons.

jsFiddle

Answer

You can use click functions to do this. here is my fiddle

$('label').click(function() {
   $('.greyBtn').addClass('glow');
 });
   $('.greyBtn').click(function() {
   $(this).removeClass('glow');
   });
  $('.cancel').click(function() {
   $('.greyBtn').removeClass('glow');
  });
Comments