如何在javascript中检查鼠标下降事件不在滚动条上
这是我的代码:如何在javascript中检查鼠标下降事件不在滚动条上,javascript,Javascript,这是我的代码: // Close the bubble when we click on the screen. document.addEventListener('mousedown', function (e) { // if ain't right click if(e.button != 2){ // hide setTimeout("bubbleDOM.style.visibility = 'hidden';", 500); } }, false); 我的问题是,当
// Close the bubble when we click on the screen.
document.addEventListener('mousedown', function (e) {
// if ain't right click
if(e.button != 2){
// hide
setTimeout("bubbleDOM.style.visibility = 'hidden';", 500);
}
}, false);
我的问题是,当用户尝试使用浏览器滚动条滚动时
设置超时生效。如何检查鼠标向下是否不在滚动条中?确保按钮位于左侧,并确保它不是冒泡事件,而不仅仅是在按钮不正确时。我建议在setTimeout中也使用一个函数,因此:
但当我点击滚动条时,气泡却隐藏了起来
// Close the bubble when we click on the screen.
document.body.addEventListener('mousedown', function(e) {
// If it's a left click and the target is the current target
if(e.button === 1 && e.target === e.currentTarget) {
// hide
setTimeout(function() {
bubbleDOM.style.visibility = 'hidden';
}, 500);
}
}, false);