mousedown 事件仅在我单击元素而不是 html 元素时才起作用。为什么以及我能做什么?
var curFocus;
$(document.body).delegate('*','mousedown', function(){
if ((this != curFocus) && // don't bother if this was the previous active element
($(curFocus).is('.field')) // if it was a .field that was blurred
) {
$('.' + $(curFocus).attr("id")).removeClass("visible"); // take action based on the blurred element
}
curFocus = this; // log the newly focussed element for the next event
});
最佳答案
<html>
标签有点笼统,它包含不可见的元素,例如 <head>
,尝试使用<body>
标签。
关于javascript - 为什么 mousedown 不能在 <html> 标签上工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4209729/