Mohamed Mahmoud Elkassas Mohamed Mahmoud Elkassas - 5 months ago 20
Javascript Question

Continous hover in JQuery

I am a beginner in programming and so JQuery user. I would like to apply a specific animations using the animate.css framework and hover handler using the JQuery. The effect is applied only once a time but I want to be repeated every time the onmousover and onmouseout executed. The code I used :

$(document).ready(function() {

$(".meal-photo-Sport").hover(function()
{
$('.meal-photo-Sport a').addClass('animated fadeInUp');

}, function(){
$('.meal-photo-Sport a').addClass('animated fadeOutDown');
})
})


thanks in advance

Answer

You could remove the classnames:

$(document).ready(function() {    

         $(".meal-photo-Sport").hover(function(){
              $('.meal-photo-Sport a')
                  .addClass('animated fadeInUp')
                  .removeClass('fadeOutDown');

         }, function(){
             $('.meal-photo-Sport a')
                 .addClass('animated fadeOutDown')
                 .removeClass('fadeInUp');
         })
})