我想在单击同一个 div 时开始和停止动画。
$('div').click(function(){
//if is the first click -->do animation in loop
//if is the second click--->stop animation
});
你是怎么做的?
我只解决了以循环开头的动画:
var play = 0;
function myAnimateGreen(){
$('green').animate(
{left:'+250px'},
1000,
);
while(play==1) {myAnimateGreen();}
}
$('green').click(function(){
play = 1;
myAnimateGreen();}
});
但我无法解决停止!