私はこのプラグインを使用していますhttp://code.google.com/p/jqueryrotate/
var angle = 0;
setInterval(function(){
angle+=3;
$("#img").rotate(angle);
},50)
#imgをクリックしたときに回転を停止したいのですが、うまくいきません。
$("#img").stopRotate();
setIntervalを停止する方法はありますか?
私はこのプラグインを使用していますhttp://code.google.com/p/jqueryrotate/
var angle = 0;
setInterval(function(){
angle+=3;
$("#img").rotate(angle);
},50)
#imgをクリックしたときに回転を停止したいのですが、うまくいきません。
$("#img").stopRotate();
setIntervalを停止する方法はありますか?
呼び出しを変数に格納するsetInterval
と、呼び出しclearInterval
を停止して停止できます。
var angle = 0;
var interval = setInterval(function(){
angle+=3;
$("#img").rotate(angle);
},50)
$("#img").click(function() {
clearInterval(interval); // stick the clearInterval in a click event
});