Solved

JQuery cycling list

Posted on 2014-03-30
3
290 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
ID: 39964852
Again, I think you are loading you event handler twice. Try loading your jquery first and then your custom script.
0
 
LVL 31

Author Closing Comment

by:Marco Gasi
ID: 39964858
Thanks
0
 
LVL 31

Author Comment

by:Marco Gasi
ID: 39964860
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

920 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