📜  如何在javascript代码示例中获取鼠标x和y

📅  最后修改于: 2022-03-11 15:03:04.058000             🧑  作者: Mango

代码示例1
document.addEventListener("mousemove", () => {
  let mousex = event.clientX; // Gets Mouse X
  let mousey = event.clientY; // Gets Mouse Y
  console.log([mousex, mousey]); // Prints data
});