jQuery click off element event

后端 未结 15 1032
無奈伤痛
無奈伤痛 2020-12-13 00:25

I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() function callback when hoverin

15条回答
  •  隐瞒了意图╮
    2020-12-13 00:28

    You're going to need to monitor the mouseDown event for the whole page, but you'll have to take note when the user is clicking inside your floating div.

    I would suggest adding a hover event to your floated div so when the user is hovering over it, mouseDown is disregarded, but when it is not being hovered over mouseDown would close it

提交回复
热议问题