jQuery的触发鼠标悬停功能时,页面加载鼠标移到元素 [英] jQuery trigger mouseover function when page loads with the mouse over the element

查看:456
本文介绍了jQuery的触发鼠标悬停功能时,页面加载鼠标移到元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
我有一个ASP.NET文件,以在它的图像元素。结果
我创建了一个鼠标悬停函数这一形象元素,它的工作的罚款。结果
现在的问题是:结果
如果鼠标已经结束的元素,当文档载入本身,鼠标悬停函数不会触发(我需要鼠标移开然后鼠标悬停再次以触发它)。结果
有没有什么办法了 $(文件)的检查。就绪功能如果鼠标已经在这个元素的顶部?如果是 - 触发鼠标悬停功能。结果
谢谢大家!


I have an ASP.NET document, with an Image element within it.
I created a mouseover function on this image element and it's working fine.
The question is:
If the mouse is ALREADY over the element when the document loads itself, the mouseover function doesn't trigger (I need to mouseout and then mouseover again in order to trigger it).
Is there any way to check in the $(document).ready function if the mouse is already on top of this element? and if yes- trigger the mouseover function.
Thanks all!

推荐答案

你为什么不使用鼠标移动事件?你可以把它通过设置一个名为movedOver为true标志,然后将该标志设置为false 鼠标离开

Why don't you use the mousemove event? You could make it fire only once by setting a flag called movedOver to true, and then setting the flag to false on mouseleave

这篇关于jQuery的触发鼠标悬停功能时,页面加载鼠标移到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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