How to disable mouseout events triggered by child elements?

后端 未结 9 1179
野的像风
野的像风 2020-11-30 21:09

Let me describe the problem in details:

I want to show an absolute positioned div when hovering over an element. That\'s really simple with jQuery and works just fin

9条回答
  •  -上瘾入骨i
    2020-11-30 21:50

    It's an old question, but it never gets obsolete. The correct answer should be the one given by bytebrite.

    I would only like to point out the difference between mouseover/mouseout and mouseenter/mouseleave. You can read a great and helpful explanation here (go to the very bottom of the page for a working demo). When you use mouseout, the event stops when the mouse enters another element, even if it's a child element. On the other side, when you use mouseleave, the event is not triggered when the mouse overs a child element, and this is the behaviour the OP would like to achieve.

提交回复
热议问题