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-02-2012, 06:05 PM   PM User | #1
aref
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
aref is an unknown quantity at this point
fadeIn in Jquery

hi everyone
I have a problem in my code, and I don't know how I can solve it. please help me. thanks. I attached my code in the blew. I need to fadein every Json data in my page, but my data just add to page without fadein. how can I fix it?

Code:
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
		<link rel="stylesheet" type="text/css" href="style.css" >
		<script type="text/javascript" src="jquery.js"></script>
		
		<script>
			$(document).ready(function(){
				var counter=0;
				$.getJSON("data.json",function(data){
					$.each(data.post,function(i,data){
						   $('#post_list').append("<li class='content-sub-menu' id='part'"+counter+"><div class='article'><h4 class='article-header'><a class='article-header-link' href='#tips'>"+data.header+"</a></h4><p class='article-body'>"+data.article+"</p><img class='picture' src='"+data.image+"'/></div></li>" ) ;
                           $('#part' + counter).fadeIn(2000);
                           counter += 1;
                 
					});
				});
			});
		</script>
		
	</head>

<body>
	<div id="post"><ul class='content-menu' id='post_list'></ul></div>
</body>
</html>
aref is offline   Reply With Quote
Old 10-02-2012, 06:55 PM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,306
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
try changing ( change outlined in red)

Code:
 $('#post_list').append("<li class='content-sub-menu' id='part'"+counter+"><div class='article'><h4 class='article-header'><a class='article-header-link' href='#tips'>"+data.header+"</a></h4><p class='article-body'>"+data.article+"</p><img class='picture' src='"+data.image+"'/></div></li>" ) ;

to

Code:
 $('#post_list').append("<li class='content-sub-menu' id='part'"+counter+" style='display:none;'><div class='article'><h4 class='article-header'><a class='article-header-link' href='#tips'>"+data.header+"</a></h4><p class='article-body'>"+data.article+"</p><img class='picture' src='"+data.image+"'/></div></li>" ) ;
basic problem is you are appending the new elements and they are not hidden so they will show immediately.
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa 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:04 PM.


Advertisement
Log in to turn off these ads.