Trigger Javascript Function when user clicks anywhere on page
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');
});
精彩评论