Here's an excerpt from my click event that determines the mouse coordinates for a click regardless of horizontal / vertical scrolling of the page or the clicked image:
$('#img1').live('click', function(e) { var locX = Math.round(e.pageX - $(this).offset().left); var locY = Math.round(e.pageY - $(this).offset().top); ... On Apr 22, 9:59 am, Charlie Park <char...@pearbudget.com> wrote: > I have a div with an overflow, so it has a scrollbar. The "what are my > mouse's coordinates" tutorials (like this > one:http://docs.jquery.com/Tutorials:Mouse_Position) > only yield > A) the coordinates of the mouse on the page (using "e.pageX" and > "e.pageY", > or > B) the absolute coordinates of the mouse, within the element, on the > page (using "e.pageX - this.offsetLeft;"). What I want to do is to > find out how far down, *within my scrolling element*, the mouse is. > > Best way to think of it: picture a calendar, like on Google Calendar. > It has a scrollbar, so 10:00 am might be the earliest-visible timeslot > (the mouse position would be at 0, 0 if it were in the top-left > corner. But within div#calendar, you could have 599 pixels hiding > above the visible section. That is, the mouse is actually at point 0, > 600. > > How can I determine how much of the div is hiding? Alternately, how > can I determine what the mouse's coordinates are, considering the > entire height of the div, and not just the visible portion of it?