开发者

Trigger Javascript Function when user clicks anywhere on page

开发者 https://www.devze.com 2023-02-21 18:21 出处:网络
I have a ModalPopupExtender that needs to be hidden whenever the user clicks anywhere else on the page, window, or scrollbar. I have a function and it works if i set it to a div tag but what about whe

I have a ModalPopupExtender that needs to be hidden whenever the user clicks anywhere else on the page, window, or scrollbar. I have a function and it works if i set it to a div tag but what about when the user clicks the windows scrollbar?

function HideList() {
    $find("<%=ModalPopupExtender1.BehaviorID%>").hide();
}

<div id=开发者_如何学Python"maindiv" onclick="HideList()">
    Elements...
</div>


AFAIK, it's not possible to target the scroll bar using JavaScript.

However, you can target the scroll event and any click event on the window:

$(window).bind('scroll click', function() {
    alert('Boo');
});
0

精彩评论

暂无评论...
验证码 换一张
取 消