Reputation: 612
I have a div inside a parent div, and when I drag it and then click a button I want to show the left value of the element being dragged.
The way my code is now, it just reads it at the beginning of page load, but if I drag the div the position left does not update.
<div id="draggableHolder">
<div id="draggable"><p>drag me around</p></div>
</div>
$('#draggable').draggable({axis: 'x'});
var position = $('#draggable').position();
$('button').on('click', function() {
console.log(position.left);
});
Basically now I always get 0, there is no update.
Upvotes: 1
Views: 40