I have some problems with this code, when I press the start button, everything works as expected, but when I want to stop the animation using clearInterval , it does not work, it just continues the loop ... What am I doing wrong?
var a = function() { $("div").animate({height:300},"slow"); $("div").animate({width:300},"slow"); $("div").animate({height:100},"slow"); $("div").animate({width:100},"slow"); } $(document).ready(function(){ $("start").click(function(){ setInterval(a,1000); }); $("stop").click(function(){ clearInterval(a); }); });
source share