when applying animation to an element - eg. div.animate() - how can i unbind that animation from sing开发者_运维问答le elements?
i've tried div.unbind() and div.unbind("animate") but didnt work..
thanks
I think you need this:
$('#div').stop(); // this stop the currently-running animation
The animation is not bind to an element, it is just an effect => you can't unbind
If you just want to stop the animation on the selected element instead of completely switching animations for all elements, simply use div.stop() or div.clearQueue()
http://api.jquery.com/clearQueue/
http://api.jquery.com/stop/
if you actually use div.stop(true), it will actually call clearQueue as well.
for a single element:
$(selector).clearQueue().stop();
精彩评论