<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
display: block;
position: absolute;
}
</style>
</head>
<body>
<div>1ddddddddddddddddddd</div>
<div>1ddddddddddddddddddd</div>
<script>
[].forEach.call(document.querySelectorAll('div'), function(el){
el.onmousedown = function(e) {
console.log("нажали");
var a = [e.pageX - el.getBoundingClientRect().left, e.pageY - el.getBoundingClientRect().top];
document.onmousemove = e => {
console.log("перемещаем");
el.style.cssText = 'left:'+(e.pageX-a[0])+'px; top:'+(e.pageY-a[1])+'px'
};
el.onmouseup = function() {
console.log("отпустили");
document.onmousemove = null;
el.onmouseup = null;
};
};
el.ondragstart = e => false;
});
</script>
</body>
</html>