Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在鼠标点击页面底部时触发事件_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何在鼠标点击页面底部时触发事件

Javascript 如何在鼠标点击页面底部时触发事件,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在尝试实现一个与windows任务栏类似的菜单栏。我想要模拟的一个属性是当鼠标进入页面底部时隐藏/显示。 如何检测鼠标何时位于页面底部 首先,是否有JQuery或类似库的插件已经实现了此操作 一个可能的解决方案是在底部使用一个不可见的div,当鼠标进入时触发事件。我想知道是否有比这更好的解决办法 如果使用jQuery不是问题 window.onmousemove= function(e){ if(e.y>= $(document).height()-10) alert('yo

我正在尝试实现一个与windows任务栏类似的菜单栏。我想要模拟的一个属性是当鼠标进入页面底部时隐藏/显示。 如何检测鼠标何时位于页面底部

首先,是否有JQuery或类似库的插件已经实现了此操作


一个可能的解决方案是在底部使用一个不可见的div,当鼠标进入时触发事件。我想知道是否有比这更好的解决办法

如果使用jQuery不是问题

window.onmousemove= function(e){
 if(e.y>= $(document).height()-10)
    alert('you did hit the bottom!');
}
行。检查这个

注意:我已经给了一个10px的呼吸空间


更新:如果使用jQuery不成问题,请摆弄类似div的任务栏-

window.onmousemove= function(e){
 if(e.y>= $(document).height()-10)
    alert('you did hit the bottom!');
}
行。检查这个

注意:我已经给了一个10px的呼吸空间


更新:摆弄像div这样的任务栏-

你可以这样做-->

JQUERY

$(document).ready(function(){
  $(document).mousemove(function(event){
    var docheight = $( document ).height() - 10; //subtracted with 10 just to be safe with checking the condition below

    if(event.pageY > docheight){
        alert("you have reached socument bottom");
         //write your code here
    }

  });
});

你可以这样做-->

JQUERY

$(document).ready(function(){
  $(document).mousemove(function(event){
    var docheight = $( document ).height() - 10; //subtracted with 10 just to be safe with checking the condition below

    if(event.pageY > docheight){
        alert("you have reached socument bottom");
         //write your code here
    }

  });
});

您是否查看了
mousemove
事件?是的,但每次移动到“触发”区域时,它都会触发一个事件。我需要只触发一次事件,或者在底部添加一个不可见区域,或者使用鼠标移动事件并测试您将在事件对象中找到的鼠标位置。是否查看了
mousemove
事件?是的,但它会为“触发”区域中的每次移动触发一个事件。我需要在底部添加一个不可见区域,或者使用鼠标移动事件并测试您将在事件objectWell中找到的鼠标位置时触发事件,这与我的解决方案有何不同?技术上没有什么不同。我的解决方案只是一个简单易懂的lil,并且有更多的解释。但是你的第一个小提琴工作不正常,我已经发布了答案,所以决定保持原样。嗯,这与我的解决方案有何不同?技术上没有什么不同。我的解决方案只是一个简单易懂的lil,并且有更多的解释。但是你的第一个解决方案工作不正常,我已经发布了答案,所以决定保持原样。