Reputation: 612
After I click a button an element's left position is animated, I need to get that new position, not the starting position.
$('button').on('click', function() {
$('div.move').animate({left: 300});
var v = $('div.move').position().left;
console.log(v);
});
Upvotes: 0
Views: 58
Reputation: 99620
You need to get the value as a callback:
$('button').on('click', function () {
$('div.move').animate({
left: 300
}, function () {
var v = $('div.move').position().left;
alert(v);
});
});
Check this fiddle
Upvotes: 2