How to get the coordinates/position of the mouse cursor, in javascript?

Asked

Viewed 3,951 times

-1

Preferably without using frameworks.

1 answer

2


You can capture this with an Event Listener:

document.querySelector('body').addEventListener('mousemove', function(event) { var posX = event.clientX, posY = event.clientY; });

  • Thank you, Luan!

  • For nothing! I’m glad I could help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.