is there any way to find out if the mouse event remains on a certain side of the element? I mean, I have a DIV with a mouseover / mouseenter event, and I want to trigger an action only if the mouse moves to the left of the DIV and to the right, but if it goes from the bottom or top, it should not call any action.
Thanks in advance.
With jQuery, you can use the offsetX property of the event like this:
$('#element').mouseout(function(e) { if (e.offsetX < 0 || e.offsetX > $(this).width()) { alert('out the side!'); } });
, - ( jQuery), , jQuery ( Chrome IE7-9). , , . 0 , , , .
pageX pageY (, offset outerWidth/outerHeight ).
pageX
pageY
offset
outerWidth
outerHeight
, AFAIK, .
.
. jQuery: http://docs.jquery.com/Tutorials:Mouse_Position
( mousemove , mouseenter/mouseleave)
, jQuery mouseout ( mouseleave?) javascript , , .
. mouse-out, (x, y) → (10, 10), 20, - 20. 30 X 10 30 Y, .
, , . jquery.hoverdir
...