How to get the position of a draggable object

后端 未结 3 1605
半阙折子戏
半阙折子戏 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:21

    You can get the width output with .resizable() and stop event. Try adding this:

    $('#dragThis').resizable({ handles: "e, w",      
          stop: function(event, ui) {
            var width = ui.size.width;
            var height = ui.size.height;
        $('#width > span').text($(this).width());
        $('#height > span').text($(this).height());
          }
       });
    

提交回复
热议问题