javascript get mouse coordinates relative to element code example
Example: js mouse position relative to element
// 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.