0

If I am using this function to make an element draggable using jQuery ui draggable:

$(document).ready(function() {
  $("#draggableSquare").draggable();
});

How can I access the co-ordinates of the element as it's moved around?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
cascavel
  • 55
  • 4
  • it seems the aswer is here http://stackoverflow.com/questions/849030/how-do-i-get-the-coordinate-position-after-using-jquery-drag-and-drop – firegnom Jan 18 '12 at 18:29
  • Does this answer your question? [How do I get the coordinate position after using jQuery drag and drop?](https://stackoverflow.com/questions/849030/how-do-i-get-the-coordinate-position-after-using-jquery-drag-and-drop) – Brian Tompsett - 汤莱恩 Jun 19 '21 at 22:07

1 Answers1

0
$( "#draggable" ).draggable({
    drag: function(event,ui) {
        //relative to container: ui.position.left and ui.position.top 
        //ralative to page: ui.offset.left and ui.offset.top
    }
});

jsFiddle

Sinetheta
  • 9,189
  • 5
  • 31
  • 52