JQuery Loop

jQuery loop. I wordpress I have a section that I add logos to.  At anytime there can be any number of logos.  Sometimes more, sometimes less.  I have them fading in and it is all hard coded.  I want to make a loop to cut down on the amount of code and also be more efficient with my coding.  Depending upon how many logos there are, my php loop on the front end makes a number  addition to the ID.  So id="customer1" id="customer2", id="customer3', etc...

My jQuery is the following and I would like to turn it into an intuitive loop.  Any suggestions?
            setTimeout(function () {
            }, 100);
            setTimeout(function () {
            }, 200);
            setTimeout(function () {
            }, 300);
            setTimeout(function () {
            }, 400);
            setTimeout(function () {
            }, 600);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
I would need to see the code but there is a method that works like this

1. Put all the images in a container
2. Hide the images
3. Show the first image
4. Make all images position absolute opacity 0
5. Make the first image position relative
6. Give the first image a transition on the opacity to fade it in
Then create a setInterval function to move the first image to the back every N seconds
.icon-container {
  width: 200px;
  margin: 0 auto;
  position: relative;
.icon-container img {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
.icon-container img:first-child {
  opacity: 1;
  transition: 1s opacity;
  position: relative;

Open in new window

  <div class="icon-container">
    <img src="images/foreground1.png" />
    <img src="images/foreground2.png" />
    <img src="images/foreground3.png" />
    <img src="images/foreground4.png" />
    <img src="images/foreground5.png" />

Open in new window

JavaScript / jQuery
$(function() {
  var container = $('.icon-container');
  setInterval(function() {
    $('img:first-child', container).appendTo(container);
  }, 1500);

Open in new window

Working sample here
What about :
var i = 1;
var max = 6; // should work if only your section have this ID : $("[id^=customer]").length;
var loopit = function () {
	$('#customer' + i).addClass('visible');
		setTimeout(loopIt, i * 100);
setTimeout(loopIt, i * 100);

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.