From what I gather, jQuery's focus() gets called before the element is focused. I believe this is so because the element's border is different when focused, and when I measure it I get the unfocused border size.
Is there a way to run code right after the 开发者_运维技巧element gets focus?
You could run your code in a timeout handler after a tiny delay.
$('.foo').focus(function() {
var foo = this;
setTimeout(function() {
$(foo).whatever();
}, 1);
});
精彩评论