KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using jquery ui for drag and drop. I am trying to get mouse position relative to div, here is my code: $( "#db_tables " ).droppable({ activeClass: "ui-state-default", hoverClass: "ui-state-hover", drop: function( event, ui ) { var x = ui.position.left - ui.offset.left; // tired event.pageX - this.offsetLeft; var y = ui.position.top - ui.offset.top; // tired event.pageY - this.offsetTop; $( '<div style="margin-top:' + y + 'px; margin-left:' + x + 'px; "></div>' ).html( ui.draggable.html() ).appendTo( this ); } }); But the position of dropped div is not correct, Can anybody please tell me what is wrong with code?
Tags (comma-separated)
Save Edits
Cancel