Consider this example where I have 2 input fields:
And consider t
You can use an extravarible to check whether b is focused before hiding b. It worked in IE, Chrome & Firefox. I don;t have any other browser. You can check it.
var focusedB = false;
$("#a").focus(function(){
$("#b").show();
});
//if b is focused by pressing tab bar.
$("#a").keydown(function(e){
if(e.which === 9){
focusedB = true;
}
});
$("#b").blur(function(){
$("#b").hide();
});
$("#a").blur(function(){
if(focusedB){
focusedB = false;
}else{
$("#b").hide();
}
});
$( "#b" ).mousedown(function() {
focusedB = true;
});