I have function/event which should be applied on all images which are under span tag. The getMousePos function gets actual position of the mouse. It should evaluate whether the mouse cursor is in the center of the image and that run zoom function. My problem is that the getMousePos gets position of the mouse only at the point, where I entered border of the image. Of sure, I need to get actual position of the mouse in the image. Image which has coords 100,100-200,200 should detect mouse position like 125,150 and similar not only the edge values like 100,200...

$(function() {

$("span img").mouseover(
getMousePos($(this), zoom);

How to correct?