jQuery run animation with defaults prevented on document load
I am trying to run an animation slideDown with some delays and a slideDown on document load, but i want it to prevent the defaults of the slideDown action as the element has position:fixed;
I believe that i am doing it wrong as it will not load at all, could you please assist;
i have it here on fiddle: http://jsfiddle.net/fLBaD/1/
and here is the code;
$(function(){
$('.initial').hide();
var initi开发者_StackOverflowal = $(".initial");
jQuery(function(){
preventDefault();
if (initial.is( ":hidden" )) {
initial.delay(3000).slideDown(1000).delay(5000).slideUp(1000);
}
});
});
Thanks :)
in the jQuery you have a lot of unnecessary code, just do:
$(".initial").delay(3000).slideDown(1000).delay(5000).slideUp(1000);
And hide the element with css (faster) so it doesnt have to load javascript to hide.
see working demo: http://jsfiddle.net/fLBaD/3/
Just do this:
$(function(){
var initial = $(".initial");
initial.hide().delay(3000).slideDown(1000).delay(5000).slideUp(1000);
});
Fiddle: http://jsfiddle.net/fLBaD/5/
精彩评论