如何使用javascript / jquery禁用鼠标悬停事件? [英] How to disable mouseover event with javascript/jquery?

查看:873
本文介绍了如何使用javascript / jquery禁用鼠标悬停事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,当用户第一次使用鼠标悬停在div上时执行一个函数,该函数需要30秒才能完成,在30秒内,如果用户再次使用鼠标悬停,则该函数将再次执行,因此我想禁用鼠标悬停事件第二次。有没有javascript或jquery代码来禁用甚至从该div?
谢谢,任何帮助都会非常感激。

In my code a function execute when user mouseover on a div for first time and the function take like 30 seconds to complete, during that 30 seconds if user mouseover the same div again , the function executes again so i want to disable mouseover event for the second time. Is there any javascript or jquery code to disable the even from that div? THanks , any help will be heartly appreciated.

推荐答案

您可以看看jquery的一个有趣的功能。 .. .one()这里是链接为它

You can have a look at an interesting feature of jquery ... .one() here is the link for it

说明:将一个处理程序附加到元素的事件中。每个元素最多执行一次处理程序。

Description: Attach a handler to an event for the elements. The handler is executed at most once per element.

第二个想法

可以给你一个想法,假设当鼠标悬停一次,只是在开始操作之前解除鼠标悬停事件的绑定,然后一旦操作结束,再次绑定它们...

I can give you one more idea, suppose when the mouse over is occurred once, just unbind the mouseover event before starting your operations, then as soon as the operations are over, bind them back again...

这篇关于如何使用javascript / jquery禁用鼠标悬停事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆