Hide a DIV when it loses focus/blur

后端 未结 11 590
长情又很酷
长情又很酷 2021-02-05 08:34

I have a JavaScript that displays a DIV (sets its display css property from \'none\' to \'normal\'. Is there a way to give it focus as well so that when I click somewhere else o

11条回答
  •  温柔的废话
    2021-02-05 08:54

    I was also looking for this and here I found the solution https://api.jquery.com/mouseleave/. This may be useful for future readers.

    The mouseleave event differs from mouseout in the way it handles event bubbling. If mouseout were used in this example, then when the mouse pointer moved out of the Inner element, the handler would be triggered. This is usually undesirable behavior. The mouseleave event, on the other hand, only triggers its handler when the mouse leaves the element it is bound to, not a descendant.

提交回复
热议问题