If an item is clicked, the event mousedownfires before focusing. You just need to set the data attribute and check it in the focus event.
Try this demo: http://jsfiddle.net/KcGcF/1/
$('a').mousedown(function(e){
var $this = $(this);
if(!$this.is(':focus')){
$this.data('mdown',true);
}
});
$('a').focus(function(e){
var $this = $(this);
var mdown = $this.data('mdown');
$this.removeData('mdown');
if(mdown){
} else {
}
});
source
share