当我点击一个按钮时它会先 .fadeIn(0); 我该怎么做? .dealy(2000); .淡出(600);并说“正在验证...”
然后它会说 “成功完全登录”
并重定向到 index.php?
我确实试过了,但没用:
function save() {
$('#save_first').html('Validating...');
$('#save_first').fadeIn(1);
$('#save_first').delay(2000);
$('#save_first').fadeOut(600);
$('#save_second').html('Success fully log in!');
$('#save_second').delay(2601);
}
HTML
header('Location: index.php');
exit();
最佳答案
将它们堆叠起来,其余部分使用回调,重定向使用 setTimeOut
var loginUser = function(){
$('#save_first').fadeIn(1).delay(2000).fadeOut(600, function(){
$('#save_second').html('Success fully log in!');
//Redirect after 2.6 seconds delay
setTimeout(function() {
window.location.href = "/index.php";
}, 2600);
});
};
然后每当你想要触发它时:
loginUser();
点击“元素”触发:
$(element).click(loginUser);
关于javascript - 如何有两个淡入淡出,一个接一个地延迟和淡出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18536148/