Javascript Execute message when mouse is on left side of page [closed]

Working fiddle fiddle

HTML

<div class="menu hide"></div>    

SCRIPT

Call Custom function when mouse is leaving ,and in that function ,if mouse is hovered from left side of Window at least by 20px then do task you want.

var menu = $('.menu');
var menuTimeout;

$(window).on('mousemove', mouseMoveHandler);

function mouseMoveHandler(e) {
  if (e.pageX < 20 || menu.is(':hover')) {
    // Show the menu if mouse is within 20 pixels from the left or we are hovering over it
    clearTimeout(menuTimeout);
    menuTimeout = null;       
    alert("left side")
  } 
}

Leave a Comment