JSFiddle - React, Tailwind, and code Playground

HTML

<div id="parent">
  <div id="child">
    Content
  </div>
</div>

CSS

#parent {
  position: relative;
  width: 900px;
  height: 900px;
}

#child {
  position: absolute;
  left: 50px;
  top: 50px;
  width: 50px;
  height: 50px;
  background-color: green;
}

JavaScript

var child = document.getElementById('child');
child.addEventListener('mousedown', start);
window.addEventListener('mouseup', end);
document.addEventListener('mousemove', mouseMoved);

var target;

function start(event) {
  target = event.target;
}

function end() {
  target = null;
}

function mouseMoved(event) {
  if (target) {
    console.log(target);
    target.style.left = event.clientX + "px";
    target.style.top = event.clientY + "px";
  }
}