Anish
Anish

Reputation: 2917

Getting Position in jQuery Animate

I am animating one image(i.e)scaling a image like

$('#img').animate({height:'300px','width':'20px'},2000);

i need to get the current height of the image during the animation. i tried step property. But its printing so many points which is unrelated to animation.

Any Idea

Upvotes: 1

Views: 2546

Answers (2)

Jeffrey
Jeffrey

Reputation: 2005

var pos = $('#img').position();
alert(pos.top + ', ' + pos.left);

See this link.

Upvotes: 0

Jeffrey
Jeffrey

Reputation: 2005

There's a step option in the animate function that allows for callbacks during the animation. In that callback you can request the position and do what you want with it.

http://jsfiddle.net/aYVUE/

Upvotes: 2

Related Questions