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 04-18-2012, 02:07 AM   PM User | #1
flight567
New Coder

 
Join Date: Mar 2012
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
flight567 is an unknown quantity at this point
newbie question about jquery

hey, sorry about the newbie question, but how exactly does one get something to say... fade in when the document is ready?
what i'm using right now (which isn't working.) is
Code:
$(document).ready(function(){
$('#body').ready(function(){
$('#body').fadeIn(slow);
});
});
any help would be appreciated!
thanks!
flight567 is offline   Reply With Quote
Old 04-18-2012, 03:09 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,530
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Just put your JavaScript at the bottom of the page (just before </body> ) and then you will not need to test for it as the document is ready at that point.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 04-18-2012, 03:21 AM   PM User | #3
flight567
New Coder

 
Join Date: Mar 2012
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
flight567 is an unknown quantity at this point
so i should fore go the external? i'm experimenting withthe thought of using a .mouseOver, do you think that would be better?
flight567 is offline   Reply With Quote
Old 04-18-2012, 11:09 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,703
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
The “anonymous” dollar function is a shortcut for $(document).ready(), I don’t understand why people still write it the long way.
Code:
<head>
…
…
<style type="text/css">
#example {display: none;}
</style>
<script type="text/javascript">
$(function() { // this is only executed when the document is ready
   $('#example').fadeIn('slow');
});
</script>
</head>
<body>
…
…
<div id="example"></div>
…
</body>
__________________
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:06 PM.


Advertisement
Log in to turn off these ads.