当前位置: 动力学知识库 > 问答 > 编程问答 >

mouseover - jQuery hover event not firing on hover

问题描述:

So if you attach some function on the hover event it won't fire if the mouse is already within th hovering area during page load, and is not moved. You actually have to move the mouse a bit to the event to fire.

Example:

  • move the mouse to the hover-effect area
  • hit the mouse with an axe
  • reload the page with F5

=> hover function not fired :(

Why?

And is there a fix?

网友答案:

This is expected functionality, hover is simply the combination of "mouseOver" and "mouseOut" so if your cursor is over the element on page load, it never technically moves over the element. Unfortunately without a mouse move, there is no way for the javascript to determine the position of the mouse, or the element it is currently over.

分享给朋友:
您可能感兴趣的文章:
随机阅读: