Solved

JQuery cycling list

Posted on 2014-03-30
3
289 Views
Last Modified: 2014-03-30
Hi all.

I'm wondering if someone can fix this issue.
Please refer to http://dev.delphicoding.com/appcdw_present.php.

You can see a blue shaded rounded rectangle with a dark-red caption where users' comments to my software should cycle one by one... but they cycle two by two!

I used this code found on the web:

		$('ul#comments li').hide();
		var i = 0;
		var delay = 3000; //millisecond delay between cycles
		function cycleThrough(){
			 var imax = $("ul#comments li").length -1;
			 $("ul#comments li:eq(" + i + ")")
					 .fadeIn(400)
					 .delay(delay)
					 .fadeOut(400, function(){
							 (i === imax) ? i=0 : ++i;
							 cycleThrough();
					 });
			 };

		cycleThrough();

Open in new window


Then, seeing the problem, I tried to write a new different code:

	$('ul#comments li').hide();
	var cycleThrough = function()
	{
		var el = $('ul#comments li:first');
		el.fadeIn(400)
			.delay(3000)
			.fadeOut(400)
			.parent().append(el);
	};
	setInterval(cycleThrough, 4000);

Open in new window


But the problem remains the same :( I can't see any wrong in the markup nor in styling, so I ask help to you.

This question is related to http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28400697.html

Thanks to all
0
Comment
Question by:Marco Gasi
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
Comment Utility
Again, I think you are loading you event handler twice. Try loading your jquery first and then your custom script.
0
 
LVL 30

Author Closing Comment

by:Marco Gasi
Comment Utility
Thanks
0
 
LVL 30

Author Comment

by:Marco Gasi
Comment Utility
I put an explanation here for future readers: the problem has been fixed moving all links to external resource into the head section from the body, where Google suggested to put them in order to speed up the page.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now