After some searching, I came up with this answer . As far as I know, you cannot actually cancel the blur event, nor can you trigger the focus event at the same time. This is what I do not understand. You can blur the focus, but you cannot focus on the blur. In any case, my solution uses the setTimeout function to trigger a 1 ms focus event after losing focus.
var o = this; oTimeout = setTimeout(function(){ o.focus(); },1);
Using mouseenter and mouseleave events, I set a boolean to refer to the blur event
$("div#box").mouseenter(function(){ changeFocus(1); }).mouseleave(function(){ changeFocus(0); });
source share