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

Popular posts from this blog

java on terminal

typing using javascript html css