How to get the position of a draggable object

后端 未结 3 1607
半阙折子戏
半阙折子戏 2020-11-29 21:39

I\'m trying to get the x and y of the draggable object using jQuery.

The scenario is, I\'m dragging and dropping an object onto another obj

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 22:33

    You can try one of these:

    $(this).position()
    

    or

    $(this).offset()
    

    The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document.

    From http://api.jquery.com/position/

提交回复
热议问题