Mouse location relative to a div? or div location relative to the viewing window?
I'm making a team members page, I want to make the pictures of the people look at where the mouse is. To do this I need to know where the mouse is in relation to the div that the image is in.
I know how to find the location of the mouse in the viewing window using .mousemove(function(e) . but I don't know how to get the location of the div with respect 开发者_StackOverflowto the viewing window. Or if I could just find the mouse location with respect to the div it would cut out the middle man.
Once I can get the coordinates, I should be able to swap out the images depending on the mouse location with if statements.
Thanks!
made a fully working example here: http://jsfiddle.net/zK7p6/1/
精彩评论