Skip to content

Instantly share code, notes, and snippets.

@joystick
Created October 8, 2013 08:50
Show Gist options
  • Select an option

  • Save joystick/6881692 to your computer and use it in GitHub Desktop.

Select an option

Save joystick/6881692 to your computer and use it in GitHub Desktop.
#container {
margin: 20px;
}
#dnd {
height: 100px;
width: 100px;
border: 2px solid red;
background: white;
padding: 10px;
}
#status {
position: absolute;
top: 400px;
height: 40px;
width: 80%;
border: 2px solid grey;
}
<!DOCTYPE html>
<html>
<head>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="container">
<div id="dnd">test</div>
<div id="status">
&nbsp;
</div>
</div>
</body>
</html>
$(function(document) {
$("#dnd").draggable({
stop: function() {
var position = $("#dnd").position();
$("#status").text( "left: " + position.left + ", top: " + position.top );
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment