Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with Jquery

    Hello!

    I am trying to do a simple fadein/fadeout function. Essentially, after I press a button, all the text will fade out, after all the text has faded out a whole bunch of other text will re-appear. Here is my code thus far:

    PHP Code:
      function fadeout(){
            $(
    '#div1').fadeOut('slow', function(){
               $(
    '#div2').fadeIn('slow')}
            )

    The part I am mostly having trouble with is to make it so that div2 is hidden until I call upon it with fadein. Any ideas?

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,628
    Thanks
    6
    Thanked 1,002 Times in 975 Posts
    Either hide it with CSS or with jQuery’s hide() function. Note that the first method should only be combined with a check if JS is enabled. I usually do it like this:
    PHP Code:
    $('body').addClass('jsenabled'); 
    and then in the stylesheet
    Code:
    .jsenabled #div2 {display: none;}
    If you were to use jQuery entirely then it should look like this:
    PHP Code:
    $('#div2').hide();
    function 
    fadeout(){
            $(
    '#div1').fadeOut('slow', function(){
               $(
    '#div2').fadeIn('slow')
            });



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •