Start and Stop setInterval animation on hover jquery


var interval = null;
interval = window.setInterval(function(){animatedCode()},3000);

function animatedCode() {
    //animation code
}

//Stop and start on hover
$('.selector').hover(function() {
    window.clearInterval(interval);    
}, function() {
    interval = window.setInterval(function(){animatedCode()},3000);
});

Latest Comments

Comments are closed.

comment on this article