当我点击一个按钮时,我会先.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();
答案 0 :(得分: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);