// 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.