JSFiddle - React, Tailwind, and code Playground

by Deepak Manwal

HTML

<div onclick="myFunction()" id="move">test</div>

CSS

div{position:absolute;}

JavaScript

function myFunction() {
    var div = document.getElementById('move');
    document.addEventListener('mousemove', function(e) {
        div.style.left = e.pageX + "px";
        div.style.top = e.pageY + "px";
    });
}