.mouse() - relative position of mouse
Gets the relative position of mouse over an element with repect to itself. mouse() will be mostly used within the listener function of mouse events.
Returns
Example 1
Find the relative position of mouse pointer inside the div box. Move the mouse cursor over the div.
JS
HTML
CSS
$.domLoaded(function() { $.get("#box1").on("mousemove", function() { // Get the relative mouse position var po = $.self().mouse(); $.get("#msg").html("Mouse is at x : " + po.x + " y : " + po.y); }); });
Result
| |||||