0

I need to get the current mouse position relative to a div.

i've tried using:

myDiv.onclick = () => {
  console.log(event.clientX) //X pos
}

and

myDiv.onclick = () => {
  console.log(event.screenX) //X pos
}

But they all return difference values depending on the screen size or browser window size, so how can i get the click position inside the div regardless of screen ?

bruhmoment
  • 98
  • 8

0 Answers0