Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Javascript Native Drag
<div id="one">
window.onload = function(){
var dragObj = null;
function draggable(id)
var obj = document.getElementById(id); = "absolute";
obj.onmousedown = function(){
dragObj = obj;
document.onmouseup = function(e){
dragObj = null;
document.onmousemove = function(e){
var x = e.pageX;
var y = e.pageY;
if(dragObj == null)
return; = x +"px"; y +"px";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.