javascript - Getting position of draggable element relative to (inside of) element -
i have draggable text , it's coordinates within element.
the text made draggable through code:
$("span.output").draggable({ stop: function(event, ui) {} }); i have piece of code supposed make draggable text child of element draggable text in:
$('.container').on('drop', function(event, ui){ $(this).append(ui.draggable); }); when try $('#text1').position(); in console when draggable text within in container, these coordinates:
object {top: 57.11805772781372, left: 779.4444580078125} unfortunately, these wrong. trying possible? if so, how can it?
this problem.
you using
$('#text1').position(); it give postion relative container.
if want position relative document use this.
$('#text1').offset(); it has have $('#text1').offset().left , $('text1').offset().right
it might help..
Comments
Post a Comment