Как получить координатную позицию после использования перетаскивания jQuery? Я хочу сохранить позицию в базе данных, так что в следующий раз, когда я нахожусь, элемент будет в том же положении.Как получить позицию перетаскиваемой кнопки
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\themes\base\jquery.ui.all.css">
<script src="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\jquery.js"></script>
<script src="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\ui\jquery.ui.core.js"></script>
<script src="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\ui\jquery.ui.widget.js"></script>
<script src="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\ui\jquery.ui.mouse.js"></script>
<script src="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\ui\jquery.ui.draggable.js"></script>
<link rel="stylesheet" href="C:\Users\Atanu\Downloads\jquery-ui-1.9.1\demos\demos.css">
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script>
$(function() {
$("#draggable").draggable({
cancel: false
});
});
$("#draggable").click(function(){
var x = $("#draggable").position();
alert("Top: " + x.top + " Left: " + x.left);
});
</script>
</head>
<body>
<button type="button" id="draggable" class="ui-widget-content">
Drag me around
</button>
<div class="demo-description">
<p>Enable draggable functionality on any DOM element. Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.</p>
</div>
<div id="start">Waiting for dragging the image get started...</div>
<div id="stop">Waiting image getting dropped...</div>
</body>
</html>
Это было отвечено еще в одном сообщении. См. Http://stackoverflow.com/questions/4903530/how-to-get-the-position-of-a-draggable-object – Hopfeeyy