2013-08-30 78 views
2

我该怎么做,当我点击一个按钮,它会首先.fadeIn(0); .dealy(2000); .fadeOut(600); and say "Validating..."那么它会说"Success fully log in"并重定向到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(); 
+1

你可以分享一些HTML的任何方式,使我能迅速的小提琴? – brbcoding

回答

5

堆叠起来并用的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); 
+0

oki但是如何在完成后将它们重定向到一侧? @charlitosJS – user2733334

+0

只需使用setTimeout函数重定向即可。我用它更新了代码。 – charlitosJS

+0

oki谢谢你! :) – user2733334