JSFiddle - React, Tailwind, and code Playground

by trkli

HTML

<body>
  <div class="wrap"></div>
  <div class="el"></div>
</body>

CSS

.wrap {
  width: 10rem;
  height: 2rem;
  background: red;
}

.el {
  position: fixed;
  width: 2rem;
  height: 2rem;
  top: 0; left: 0;
  background: yellow;
}

JavaScript

$('.wrap').on('mousemove', function(e){
    $('div').css('top', e.pageY);
    $('div').css('left', e.pageX);
});