JSFiddle - React, Tailwind, and code Playground
HTML
<div id="DragDiv" style="position:absolute; width:300px;">
<label draggable="true" >1232</label>
<label>1231112</label>
</div>
JavaScript
var rDrag = {
o: null,
init: function (o) {
if( typeof(o.length) == 'number' ){
for(x in o){
this.init(o[x]);
}
}else if( typeof(o) == 'object' ){
o.onmousedown = this.start;
}
},
start: function (e) {
var o;
e = rDrag.fixEvent(e);
e.preventDefault && e.preventDefault();
rDrag.o = o = this;
o.x = e.clientX - rDrag.o.offsetLeft;
o.y = e.clientY - rDrag.o.offsetTop;
document.onmousemove = rDrag.move;
document.onmouseup = rDrag.end;
},
move: function (e) {
e = rDrag.fixEvent(e);
var oLeft, oTop;
oLeft = e.clientX - rDrag.o.x;
oTop = e.clientY - rDrag.o.y;
},
end: function (e) {
e = rDrag.fixEvent(e);
rDrag.o = document.onmousemove = document.onmouseup = null;
},
fixEvent: function (e) {
return e;
}
}
//var obj = document.getElementById('draggable1');
var obj = document.getElementsByTagName('div');
rDrag.init(obj);