我有两个输入
字段。第二个 input
开始聚焦。然后我想 fadeOut
两个 input
,让第二个 input
保持专注直到结束。最后,我想 fadeIn
两个 input
并以 first input
为焦点结束。
但是,我不想看到“故障”,即第二个 input
在 fadeIn
完成后瞬间获得焦点,然后是第一个 input
紧随其后。
这是我尝试过的(参见 fiddle here ):
// Focus the second input field
$('input').eq(1).focus();
// Fade out both input fields
$('div').fadeOut();
// Fade in both input fields
$('div').fadeIn(function () {
// Causes a "transition glitch"
$('input').eq(0).focus();
});
有没有办法“预聚焦”第二个 input
字段?
最佳答案
怎么样:
// Focus the second input field
$('input').eq(1).focus();
// Fade out both input fields
$('div').animate({'opacity': 0}, function() {
$('input').eq(0).focus();
// Fade in both input fields
$('div').animate({'opacity': 1});
});
关于javascript - 淡入前预对焦输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14114459/