我正在使用这个函数在母版页中显示div标签
$("#div_NotificationOuter").show(1000);
$("#div_NotificationOuter").animate({ bottom: '+=30px' }, 4000);但在一些页面中,我有文本字段,当这个div标签显示字段时,会失去焦点。我如何在所有形式的文本字段中保持焦点,甚至显示div标签。
发布于 2012-03-17 22:33:34
您可以使用以下代码监控最后选择的输入字段:
var lastFocusedElement = '';
// This would catch any input field - so you could add your forms selector too.
// for example : $("#myForm:input")
$(":input").focus(function () {
lastFocusedElement = $(this);
});然后使用animate中的complete回调函数:
$("#div_NotificationOuter").animate({ bottom: '+=30px' }, 4000,function(){
if (lastFocusedElement != ''){
lastFocusedElement.trigger('focus');
}
});https://stackoverflow.com/questions/9750729
复制相似问题