javascript - 如何首先找到鼠标点击,如果没有点击,然后再寻找鼠标悬停

标签 javascript jquery mouseover mouseclick-event onmouseclick

如何先找到mouseclick,如果没有点击,然后再寻找mouseover

我在两个鼠标事件中实现了两种类型的功能。一个在 mouseover 中,另一个在 mouseclick 中。

如果我点击,我需要首先触发 mouseclick 事件,而不是 mouseover 事件。我知道默认情况下,首先触发 mouseover 。但如何实现这种场景。

代码:

$('.example').mouseover(function (event) {
    // ...
    //mouse over logic
    // ...
});

$('.example').mouseclick(function (event) {
    // ...
    //mouse click logic
    // ...
});

注意:

Alos, I tried with timer, set control flags but in each try, only mouseover is triggerd first. Both mouseover and mouseclick has different functionalities. If both are same, then we can put in common. But, here the case is different. I had also searched over the net for this. But nothing helped till now. Thanks.

最佳答案

在点击事件中定义鼠标悬停事件怎么样?

示例:

$('.example').mouseclick(function (event) {
    // ...
    //mouse click logic
    // ...
    $(body).bind('onmouseover', '.example'){
         // mouseover logic
    }
 });

我没有经过严格的测试...

关于javascript - 如何首先找到鼠标点击,如果没有点击,然后再寻找鼠标悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41142501/

相关文章:

javascript - 如何获取getroute生成的marker的onclick事件

javascript - 如何制作多个可移动元素

javascript - insertBefore() 一个iframe jquery问题

javascript - $ 不是 Drupal 上的函数错误

Jquery:如何向 mouseleave 添加延迟,以便如果有人无意间将鼠标悬停在元素上,它仍然保持打开状态

javascript - 如何从 Javascript 或 Jquery 中的数组中选择随机值?

javascript - 在新窗口中从 javascript 打开 MVC 4 View

javascript - Chart.js 响应选项 - 图表未填充容器

javascript - 在鼠标悬停时获取产品详细信息

jQuery:选择特定 DIV 下嵌套的所有 DIV