How do I get the coordinate position after using jQuery drag and drop?

前端 未结 9 1358
北荒
北荒 2020-11-29 20:36

How do I get the coordinate position after using jQuery drag and drop? I want to save the coordinate to a database, so that next time I visit, the item will be in that posi

9条回答
  •  孤独总比滥情好
    2020-11-29 20:57

    Had the same problem. My solution is next:

    $("#element").droppable({
        drop: function( event, ui ) {
    
            // position of the draggable minus position of the droppable
            // relative to the document
            var $newPosX = ui.offset.left - $(this).offset().left;
            var $newPosY = ui.offset.top - $(this).offset().top;
    
        }
    });
    

提交回复
热议问题