Fuxi
Fuxi

Reputation: 7599

jQuery: stop animation from element?

when applying animation to an element - eg. div.animate() - how can i unbind that animation from single elements?

i've tried div.unbind() and div.unbind("animate") but didnt work..

thanks

Upvotes: 0

Views: 4317

Answers (3)

BCsongor
BCsongor

Reputation: 869

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

Upvotes: 3

felixsigl
felixsigl

Reputation: 2920

for a single element:

$(selector).clearQueue().stop();

Upvotes: 2

JohnP
JohnP

Reputation: 50019

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.

Upvotes: 3

Related Questions