更新时间:2023-01-26 22:28:19
好吧,可行的方法是将焦点"处理程序绑定到所有内容,并且您知道当您不在<div>
中时另一个焦点"事件.
Well, what might work would be to bind a "focus" handler to everything, and you know when you're not in the <div>
when you get a "focus" event elsewhere.
$('body').live('focus', (function() {
var inDiv = false;
return function(e) {
if ($(this).closest('#theDiv').length)
inDiv = true;
else {
if (inDiv)
alert("just lost focus!");
inDiv = false;
}
};
});