📜  js 鼠标相对于元素的位置 - Javascript 代码示例

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

代码示例1
// e = Mouse click event.
let rect = e.target.getBoundingClientRect();
let x = e.clientX - rect.left; //x position within the element.
let y = e.clientY - rect.top;  //y position within the element.