仅当我单击一个元素而不是html元素时,mousedown-event才起作用。为什么,我该怎么办?
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>
标记。