6. Hover Subject alternative to addClass() and removeClass()


#1



$(document).ready(function(){
  $("div").hover(function(){
     $(this).toggleClass("active"); 
  });
});

isn't this example does the same thing? Instead of writing unnecessary code as:


$('div').hover(
    function(){
      $(this).addClass('active');
   },
   function(){
      $(this).removeClass('active');
   }
);


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.