tags:

views:

57

answers:

1

How could I know with help of jQuery as to which edge (ie. border) of the div box mouse cursor is on?

+3  A: 

You have to use the pageX and pageY of the jQuery event:

$("#myDiv").mousemove( e )
{
   var left  = (e.pageX - $(this).offset().left ) / $(this).width() * 100; // 0 to 100
   var top = (e.pageY - $(this).offset().top ) / $(this).height() * 100; // 0 to 100

   if ( left > 90 && top > 90 ) console.log ('the mouse is in the bottom right corner ' );
}
Ghommey