2013-10-09 27 views

回答

0

可惜你不能在focus處理事件訪問blur射擊元素。

但是你可以把它保存爲一個全局變量:

var $blurLastFiredOn = $(); 

$el.blur(function() { 
    $blurLastFiredOn = $(this); 
    // do stuff 
}); 

$otherEl.focus(function() { 
    $blurLastFiredOn.doStuff(); 
}); 

或者,如果你願意,以避免全局變量,使用data

$el.blur(function() { 
    $('body').data('blur-last-fired-on', $(this)); 
    // do stuff 
}); 

$otherEl.focus(function() { 
    $('body').data('blur-last-fired-on').doStuff(); 
});