Jump to content

FadeIn and fadeOut sequence using jquery and animate.css

Recommended Posts

I want to create a main header where texts will bounce in, in 0.5s intervals and then at the same time it will all fade out, 1s interval again then new text will bounce in same intervals again and fade out. When it finished I want it to start from the beginning. I use animate.css, twitter-bootstrap and jquery. I have tried a few different ways, but so far I couldnt even get it to fade out after a short delay or if it fades out, it wont bounce in.



$( document ).ready(function() {  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig'),  $('.main2').addClass(3000, 'animated fadeOutDownBig')});$( document ).ready(function() {  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig');  $( ".main2" ).toggle( "puff" ).delay(3000);});$( document ).ready(function() {  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig');  $( ".main2" ).removeClass( 'bt_visible animated fadeInDownBig').delay(3000);  $( '.main2' ).addClass( 'bt_visible animated fadeOutDownBig').delay(3000);}); 
Link to post
Share on other sites

Why do you have 3 sections for the document ready event? All of that code is going to run at the same time, why is it in 3 sections?What are you trying to do with this line:$('.main2').addClass(3000, 'animated fadeOutDownBig')According to the documentation I see, addClass takes a single parameter, either a string or a function. You're trying to pass 2 parameters there.http://api.jquery.com/addclass/Also, in your first section, you end one line with a comma instead of a semicolon, and there's no semicolon on the other line.When you put everything together instead of splitting it up into 3 pieces, this is what you're telling it to do:

  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig');  $('.main2').addClass(3000, 'animated fadeOutDownBig');  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig'); // this is the same as the first line  $( ".main2" ).toggle( "puff" ).delay(3000);  $( '.main2' ).addClass( 'bt_visible animated fadeInDownBig'); // the same line again  $( ".main2" ).removeClass( 'bt_visible animated fadeInDownBig').delay(3000);  $( '.main2' ).addClass( 'bt_visible animated fadeOutDownBig').delay(3000);
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...