setTimeOut jquery problem
i would like to scroll the win开发者_如何学Cdow to the top, pause my animation for 1 second, and then use a fadeOut to erase the content, but this code doesn't work, do you know why?
$('#link').bind('click', function(){
preloading.show();
$('html,body').animate({'scrollTop':0}, 300, function(){
$('#myDiv').setTimeout(function(){
$(this).empty()
.append(conteneurBio).hide()
.fadeIn('slow', function(){
preloading.hide();
});
}, 1000);
});
Wouldn't this work too?
$('html,body').animate({'scrollTop':0}, 300, function() {
$('#myDiv')
.empty()
.hide()
.append(conteneurBio)
.delay(1000)
.fadeIn('slow', function() { preloading.hide(); }
});
You're missing one set of closing });
s:
$('#link').bind('click', function(){
preloading.show();
$('html,body').animate({'scrollTop':0}, 300, function()
{
setTimeout(function(){
$('#myDiv').empty()
.append(conteneurBio).hide()
.fadeIn('slow', function(){
preloading.hide();
});
}, 1000);
});
});
used something like: http://jsbeautifier.org/ it helps you find any missing brackets/braces in your javascript, especially when you don't have an editor that does the indentation for you.
Joseph posted before me with the correct answer though, you're missing a "});" at the end
精彩评论