var box = document.querySelector('.box');
box.addEventListener('mousemove',function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
console.log('x的坐标是'+x+','+'y的坐标是'+y);
})
<div class="box">
</div>
.box{
width: 150px;
height: 150px;
background-color: skyblue;
margin:auto 100px;
}