Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-27-2011, 01:14 PM   PM User | #1
blug
New to the CF scene

 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
blug is an unknown quantity at this point
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?
blug is offline   Reply With Quote
Old 10-27-2011, 04:24 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,613
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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')
        });

__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:14 AM.


Advertisement
Log in to turn off these ads.