Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Fade-In OnLoad?

Okay what I am simply looking for is a short/easy script that will allow me to replace the DIV name so that I can have multiple divs on a page fadein once loaded (including images within them).

Any ideas?

Thank you!

like image 754
Aaron Brewer Avatar asked Oct 22 '11 17:10

Aaron Brewer


People also ask

How do I fade an element in jQuery?

The jQuery fadeIn() method is used to fade in a hidden element. Syntax: $(selector).fadeIn(speed,callback); The optional speed parameter specifies the duration of the effect.

What is fadeIn function in jQuery?

jQuery fadeIn() Method The fadeIn() method gradually changes the opacity, for selected elements, from hidden to visible (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeOut() method.

Which of the following is not the fade method in jQuery?

6. Which of the following is not the fade method in jQuery? Explanation: jQuery has various fade methods including fadeout(), fadeTo(), fadeToggle(), fadeIn(). The syntax of fadeIn() is $(selector).

What is fadeIn fadeOut effect?

The Fade In/Fade Out behavior lets you dissolve into and out of any object by ramping the opacity of the object from 0 percent to 100 percent at the start, and then back to 0 percent at the end. You can eliminate the fade-in or fade-out effect by setting the duration of the Fade In Time or Fade Out Time to 0 frames.


2 Answers

Give the divs a common class (e.g. "fade") and use code similar to this

$(document).ready(function(){
    $(".fade").hide(0).delay(500).fadeIn(3000)
});

http://jsfiddle.net/5td73/

like image 172
Joseph Marikle Avatar answered Oct 03 '22 21:10

Joseph Marikle


Put this code in your javascript file, for each element you want to fade it add the class="fadeOnLoad" code and make sure to add display: none to the css for any elements you want to have hidden on load:

$(document).ready(function() {
       $('.fadeOnLoad').fadeIn('slow');
);
like image 34
Joost Avatar answered Oct 03 '22 21:10

Joost