How can I find current element on mouseover using jQuery?

前端 未结 8 1725
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 07:10

How can I get the class name of the current element that is on mouseover? For example \"enter<

8条回答
  •  庸人自扰
    2020-12-24 07:48

    What most people have neglected is this request from the OP:

    When mouse over div from a

    Meaning you need to know you've hovered from a specific type of element, not just from any element.

    I made a global var, changing to true on the mouseleave of specific elements, in your case an a element. Then, inside the hover function you need to check that it's true.

    Here's a Demo

    Edit: Updated fiddle demo with edge cases when hovering from a element not directly onto the div.

提交回复
热议问题