Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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.
 
PREVIOUS NEXT
Tagged: #js #mouse #position #relative #element
ADD COMMENT
Topic
Name
1+3 =