views:

69

answers:

2

I am using this code to make a certain div (#extras) fade out.

$(document).ready(function() {

            for(var i = 1; i <= pageLimit; i++) {
                $('body').append('<div id="page' + i + '" name="page' + i + '" class="touch"></ div>' ); 
            }

            $('body').append('<div id="extras" class="showUp">..all content needed goes in heree...</div>');
            $(window).load(function() {
                $('div#extras').delay(100).fadeOut(4000); 
            });
});

CSS:

div#extras {
    height:100%;
}

&

body > div.showUp {
    display: block !important;
    height:100%;
}

It fades out nicely, but then pops back up once its done the fading animation. How would I make it stay faded? In another function I will have it fade back in.

This is the defaulted css I have from the JQtouch sample I have been working on..

body > * {
background: transparent;
-webkit-backface-visibility: hidden;
display: none;
position: absolute;
left: 0;
text-align:center;
width: 100%;
-webkit-transform: translate3d(0,0,0) rotate(0) scale(1);
height: 100% !important;
}

Thanks!

Would the fact that the extras div was inserted into the page by the .append() function have anything to do with making it pop back up?

A: 

how about just using .fadeTo(0) (or some other number if you want it to show 'opaquely' i.e. .fadeTo(250) etc...

your solution would be:

$("#extras").fadeTo(500, 0);

this might be an avenue worth exploring.

jim

[edit] - see http://api.jquery.com/fadeTo/

jim
Just tried that, it makes it disappear without fading at all, but it does stay invisible
Annie
Annie, in that case then, try: .fadeTo(500, 0) where 500 is the required duration in milliseconds (i.e. that would be half a second. should work!! :) [see edit above]
jim
"fast" = 200 milliseconds, "slow" = 600 milliseconds, default is 400 milliseconds if any other string is used (not a number). Number is milliseconds.
Mark Schultheiss
+2  A: 

I've had success using:

$("#element").fadeTo("fast", 0.33);

The speed parameter can be set to "slow" if you want to make the fading take more time.

PIM
Thanks! I ended up using $('div#extras').delay(100).fadeTo(3000, 0);and its working perfectly :)
Annie
"fast" = 200 milliseconds, "slow" = 600 milliseconds, default is 400 milliseconds if any other string is used (not a number). Number is milliseconds.
Mark Schultheiss