On mouse out add class, remove class

On mouse out add class, remove class

Hi Jake;

On mouse over I want to add btn-primary and remove btn-default. It works fine but on mouse out I want to remove class btn-primary and add class btn-default.

The second part doesn't work! I wonder what I am doing wrong.

Thanks

  1.  $( ".btn-default" ).mouseover(function()
  2.         {
  3.             $(this).addClass("btn-primary");
  4.             $(this).removeClass("btn-default hovered");
  5.         });
  6.  
  7.  $( ".btn-primary" ).mouseout(function()
  8.         {
  9.             alert('out');
  10.             $(this).removeClass("btn-primary");
  11.             $(this).addClass("btn-default");
  12.         });