JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div1">aaa</div>
CSS
#div1 {
position: absolute;
width: 100px;
height: 100px;
top: 20px;
left: 20px;
border: 1pt red solid;
}
JavaScript
$(document).mousedrag(function(e) {
var x = e.pageX;
var y = e.pageY;
if((x >= X && x <= X+W) &&
(y >= Y && y <= Y+H))
alert("in");
});
var el = "#div1";
var W = $(el).width();
var H = $(el).height();
var X = $(el).position().left;
var Y = $(el).position().top;