Exact location coordinates using javascript e.clientX - box.offsetLeft
let box = document.querySelector('.box');
let doc = document.body;
document.addEventListener('mousemove',(e)=>{
x = e.clientX - box.offsetLeft;
y = e.clientY - box.offsetTop;
doc.textContent=x+' '+y;
});
Comments
Post a Comment