The mousedown-event only works if I click an elemnt, not the html-element. Why and What can I do about it?
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
});
The
<html>tag is a bit to general, it includes non-visible elements like the<head>, try using the<body>tag.