Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Jquery ~ FadeIn on page load
Old 04-22-2009, 04:58 PM Jquery ~ FadeIn on page load
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
I want the following script to fade in when the page loads.. but it doesn't seem to work. What could be wrong?
HTML Code:
<html>
<head>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
  $(document).ready(function(){
    
    $("div").load(function () {
      $("div:hidden:first").fadeIn("slow");
    });

  });
</script>

<style type="text/css">
div
{
}
div#one
{
margin-left: 15%;
}
div#two
{
margin-top:-3.7%; margin-left:70%;
}

</style>

</head>

<body>
<br><br><br><br>
<br><div id="one">
<span style="font-size: 25"><b>Who</b></span>
<br>
<i> &nbsp;I am </i>
</div>

<div id="two">
<span style="font-size: 25"><b >What</b></span><br>
<i> I've done </i>
</div>
</body>
</html>
__________________
"If you say something interesting, people will remember your name" ~ Anonymous


Please login or register to view this content. Registration is FREE
.asp <- Irony
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-22-2009, 05:09 PM Re: Jquery ~ FadeIn on page load
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
When the .load method is used on an HTML element, it is an AJAX call. If you use it on the window, however, it is a page load event, exactly like the normal JavaScript onload event, except that it may appear in multiple places throughout the script:

Code:
$(window).load(function() {
//do stuff
});
Note that there is no need to put this inside of the $(document).ready(), which is a separate loading event. $(document).ready() waits for the HTML to load, but not the images. $(window).load() will wait for all of the images to load, in addition to the HTML.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 04-22-2009 at 05:10 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-22-2009, 08:31 PM Re: Jquery ~ FadeIn on page load
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Thanks, yeah that makes sense... but the script still doesn't work.

$(window).load(function () {
$("div:hidden:first").fadeIn("slow");
});

is what I put in instead.
__________________
"If you say something interesting, people will remember your name" ~ Anonymous


Please login or register to view this content. Registration is FREE
.asp <- Irony
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Old 04-22-2009, 10:43 PM Re: Jquery ~ FadeIn on page load
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Why don't you hide the divs first? You can't fade in something that isn't hidden first.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-23-2009, 03:47 PM Re: Jquery ~ FadeIn on page load
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Ah... yep.
Works perfectly! thanks so much!
Althought I've run into another problem... Jquery's documentary isn't very clear about the proper syntax for 'effects' like explode...
How would I correctly format the following?
HTML Code:
 $(window).load(function(){
 $("p").fadeIn("slow", function() {$("p").click(function () {
      $("p").hide("explode", {}, 1000, function() {
      $("div").fadeIn("slow");
    }); 
});});
});
__________________
"If you say something interesting, people will remember your name" ~ Anonymous


Please login or register to view this content. Registration is FREE
.asp <- Irony

Last edited by Zoltar1992; 04-23-2009 at 03:50 PM..
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Jquery ~ FadeIn on page load
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38169 seconds with 12 queries