How to disable mouseout events triggered by child elements?

后端 未结 9 1208
野的像风
野的像风 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条回答
  •  一个人的身影
    2020-11-30 21:43

    I'm simply checking if the mouse-coordinates is outside the element in the mouseout-event.

    It works but it's alot of code for such a simple thing :(

    function mouseOut(e)
    {
        var pos = GetMousePositionInElement(e, element);
        if (pos.x < 0 || pos.x >= element.size.X || pos.y < 0 || pos.y >= element.size.Y)
        {
            RealMouseOut();
        }
        else
        {
             //Hit a child-element
        }
    }
    

    Code cut down for readability, won't work out of the box.

提交回复
热议问题