首页 \ 问答 \ 有没有办法让鼠标滚轮在Javascript中触发“悬停”事件?(Is there a way to make a mousewheel trigger the “hover” event in Javascript?)

有没有办法让鼠标滚轮在Javascript中触发“悬停”事件?(Is there a way to make a mousewheel trigger the “hover” event in Javascript?)

默认情况下,如果用户使用鼠标滚轮向下滚动页面,则不会触发任何悬停事件。 有没有办法改变这一点,只要指针悬停在div上,它将触发悬停事件,无论用户是否使用鼠标或鼠标滚轮将其移动到那里?

$(window).load(function() {
  $(document).bind('mousewheel', function(e) {
    console.log(e.pageX);
    console.log(e.pageY);
    var e1 = $.Event('mouseenter');
    e1.pageX = e.pageX + 1;
    e1.pageY = e.pageY;
    $('img').trigger(e1);

    var e2 = $.Event('mousemove');
    e2.pageX = e.pageX + 1;
    e2.pageY = e.pageY;
    $('img').trigger(e2);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

编辑:上面的代码触发了悬停事件,但它没有特别选择任何图像,它只是在每次鼠标移动时触发悬停事件。


By default, if a user uses the mousewheel to scroll down the page, it doesn't trigger any of the hover events. Is there a way to change this so that as long as the pointer is hovering over a div, it will trigger the hover event whether the user used the mouse or the mousewheel to move it there?

$(window).load(function() {
  $(document).bind('mousewheel', function(e) {
    console.log(e.pageX);
    console.log(e.pageY);
    var e1 = $.Event('mouseenter');
    e1.pageX = e.pageX + 1;
    e1.pageY = e.pageY;
    $('img').trigger(e1);

    var e2 = $.Event('mousemove');
    e2.pageX = e.pageX + 1;
    e2.pageY = e.pageY;
    $('img').trigger(e2);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Edit: The above code is triggering a hover event, but it's not selecting any image in particular, it's just triggering hover events on every mouse move.


原文:https://stackoverflow.com/questions/37691886
更新时间:2023-06-30 08:06

最满意答案

执行JavaScript的唯一客户端类型是

  • GUI虚拟用户(针对完整浏览器运行的QTP)
  • Citrix | RDP针对完整浏览器运行
  • TruClient

您所看到的是执行的JavaScript作为一组显式请求的输出。


The only client types which execute JavaScript are

  • GUI Virtual users (QTP Operating Against Full Browsers)
  • Citrix|RDP operating against full browsers
  • TruClient

What you are seeing is the output of the executed JavaScript as a set of explicit requests.

相关问答

更多
  • 状态随着每个请求而变化。 因此,几乎每个请求(当它存在时)都需要关联ViewState。 还有jsessionstate出现在Java应用程序上,ViewState通常与ASP和ASP.Net相关联 State is something which changes with every request. So, ViewState is something you will need to correlate for almost every request (when it is present). Th ...
  • 执行JavaScript的唯一客户端类型是 GUI虚拟用户(针对完整浏览器运行的QTP) Citrix | RDP针对完整浏览器运行 TruClient 您所看到的是执行的JavaScript作为一组显式请求的输出。 The only client types which execute JavaScript are GUI Virtual users (QTP Operating Against Full Browsers) Citrix|RDP operating against full browse ...
  • 根据您的电子邮件,您要执行的操作是处理Outlook未运行时到达的邮件。 在这种情况下,NewMailEx将不会触发,因为在您的代码未运行时Exchange服务器已收到该消息。 最好的办法是在启动时使用Items.Restrict或Items,Find / FindNext简单地读取收件箱中的所有未读邮件。 或者更好的是,使用增量更改同步API: http : //www.dimastr.com/redemption/rdofoldersynchronizer.htm Based on your email ...
  • 不确定链接的加密内容。 它似乎是纯文本,请澄清.... 它似乎可能是临时重定向链接,其中重定向在会话结束时消失。 我将寻找如何使用本地代码获得或计算开始时的动态组件。 Adding a header solved this: web_add_header("Cookie"," JSESSIONID=dummy");
  • 各种ScriprtEngine.eval()方法都有一个返回值。 只是以某种方式将其打印并将其打印到所需的输出,例如STDOUT或游戏控制台。 The various ScriprtEngine.eval() methods all have a return value. Just somehow stringfy it and print it to the desired output, e.g. STDOUT or ingame console.
  • 您的问题有两种可能的解决方案: 1)如果您正在使用“新用户模拟”(运行时设置 - >重放取消选中“为每次迭代模拟新用户”(第一个选项)) 如果你不想做(1)那么: 2)将登录信息放入操作中。 当检查“为每次迭代模拟新用户”时,我们切断了迭代之间的所有连接,但由于init只发生一次,在迭代之前,我们在init之后执行。 There are two possible solutions for your issue: 1) If you are using "new user simulation" (Runt ...
  • 如果您认为真的很重要,您需要做的就是从球形坐标转换为直角坐标 。 我不确定它是否确实如此,因为java.awt.Polygon只是一个包含值对的数据结构。 如果你阅读javadocs,他们会说 Polygon类封装了坐标空间内封闭的二维区域的描述。 该区域由任意数量的线段限定,每个线段都是多边形的一侧。 在内部,多边形包括(x,y)坐标对的列表,其中每对定义多边形的顶点,并且两个连续的对是作为多边形一侧的线的端点。 第一个和最后一对(x,y)点由关闭多边形的线段连接。 他们碰巧将这些点标记为x和y,这使得我 ...
  • 您需要将%JAVA_HOME%\bin添加到路径的最开头。 这是因为Java也安装在%SystemRoot%\system32 。 如果将%JAVA_HOME%\bin添加到路径的开头,将使用JAVA_HOME安装的Java。 You need to add the %JAVA_HOME%\bin to the very beginning of your path. This is because Java is installed in your %SystemRoot%\system32, too. ...
  • 我相信您的问题与您使用本地服务器直接相关。 预览分析的目的是允许您将本地更改与远程 SonarQube服务器上的更改进行比较。 由于您的远程服务器每晚都会更新,因此针对它运行预览会显示您当天引入的问题。 相反,您正在针对本地实例运行,该实例将通过完整分析进行更新...从不? 哪个(如果是真的)将是您的所有问题都显示为新的问题。 要对远程服务器执行预览分析,您将需要全局“ 执行预览分析”权限和相关项目的项目级“浏览”权限 。 如果由于某种原因你无法获得这些权限(这可能是你运行本地SonarQube服务器的原因 ...
  • 如果您可以假定所有整数都是正数,那么它会大大简化问题。 你可以遍历数组来找到总和,然后再走一步,直到你(可能)找到两个和数相等的点。 这样做的原因是,向左或向右移动总是会增加/减少总和。 但是,可能存在零值,这些也需要考虑。 public List getPosition(int[] array) { List result = new ArrayList(); // first walk through the array to de ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。