How to obtain the position of the mouse over a DOM element, is it a child of relative element (in JavaScript)?
Here's a way I want to get the position of the mouse in an element. It returns the y value in a standard axis (below -> top) or in the web axis (above -> below). Get the position of
/ * In relation to the given element, the mouse event in a standard axis system is the standard axis system: the original (0, 0) starts from the bottom-left side and 'y 'Is growing and is right for' X '. * / Function GetMousePositionInElement (ev, element) {var offset = element.offset (); Var below = offset.top + element.height (); Var x = ev.pageX - offset.left; Var y = plane - ev.pageY; Return {x: x, y: y, y_fromTop: element.height () - y}; }
This requires jQuery.
No comments:
Post a Comment