Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:01:17+00:00 2026-06-06T04:01:17+00:00

With some help from SO, I have a bit of javascript/jquery that cycles through

  • 0

With some help from SO, I have a bit of javascript/jquery that cycles through some logos, fading them in and out. I’ve been trying to modify it to fade two logos, that are side by side, at once.

You can see a jsfiddle version of my code here : http://jsfiddle.net/BvLb4/3/

As you can see, i thought creating a different class for the left and right logo would be a good way to position two logos side by side. So my html now looks like this:

        <div id="img0" class="logo">
        <img src="http://i.imgur.com/JeBWX.jpg"/>
        </div>
        <div id="img1" class="logo2">
        <img src="http://i.imgur.com/DyyY3.jpg"/>
        </div>
        <div id="img2" class="logo">
        <img src="http://i.imgur.com/aVDZ1.jpg"/>
        </div>
        <div id="img3" class="logo2">
        <img src="http://i.imgur.com/JxLQt.jpg"/>
        </div>

I’m having trouble changing the recursive loop i had for a single logo to work with two at a time:

$(document).ready(function (){

    var fadeDuration = 1000;
    var timeBetweenFade = 3000;
    var totalLogos = $('.logo').length + $('.logo2').length;
    var currentLogo;
    var idx = 0;

    var loop = function(idx, totalLogos) {
        var currentLogo = "#img" + idx;
        $(currentLogo)
        .delay(100)
        .fadeIn(fadeDuration)
        .delay(timeBetweenFade)
        .fadeOut(fadeDuration, function(){
            loop( (idx + 1) % totalLogos, totalLogos);
        });
    }
    loop(0, totalLogos);
});

My initial thought was to create an additional var currentLogo2 = "#img" + (idx+1); , apply all the same methods to it as well as currentLogo and then increment the idx by 2. It makes sense in my head but so far my attempts to implement it have not been successful and im generally not sure if that’s the best approach anyway as the codes a bit repetitive. What would you suggest as a solution to getting a loop of logos that fade in and out two(or more) at a time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:01:20+00:00Added an answer on June 6, 2026 at 4:01 am

    None of the answers seemed to solve the problem but i eventually got to a solution myself. You can view the demo of the solution here: http://jsfiddle.net/BvLb4/9/ . For anyone who comes across this in the future it would be easy to alter for however many images you wanted side-by-side.

    This was very much a noob trial and error approach so if anyone has any suggestions for improvement do comment!

    JS:

    $(document).ready(function (){
    
        var fadeDuration = 1000;
        var timeBetweenFade = 3000;
        var totalCycles = ($('.logo').length) /2;
        var idx = 0;
    
        var loop = function(idx, totalCycles) {
            var currentLogo = ".img" + idx;
            $(currentLogo).delay(100);
            $(currentLogo).fadeIn(fadeDuration);
            $(currentLogo).delay(timeBetweenFade);
            $(currentLogo).fadeOut(fadeDuration,
            function(){
                idx++;
                if(idx > totalCycles){
                    idx = 0;
                }
                loop( idx, totalCycles);
    
            });
    
        }
        loop(0, totalCycles);
    });​
    

    HTML:

    //link js and jquery here
    <div id="container">
    
            <div id="logos_content">
            <h2>Associates</h2>
            <div class="logo img0">
            <img src="http://i.imgur.com/JeBWX.jpg"/>
            </div>
            <div class="logo img0">
            <img src="http://i.imgur.com/DyyY3.jpg"/>
            </div>
            <div class="logo img1">
            <img src="http://i.imgur.com/aVDZ1.jpg"/>
            </div>
            <div class="logo img1">
            <img src="http://i.imgur.com/JxLQt.jpg"/>
            </div>
            </div>
    
    </div>
    

    CSS:

    #container
    {
        width: 400px;
        height: 200px;
        background-color: DodgerBlue;
    }
    img { max-width: 100% }
    
    #logos_content
        {
        padding: 0.5em 3em;
        height: 150px;
        }
            .logo
            {
            float: left;        
            display: none;
            max-width: 45%;
            position:relative;
            margin-right:0.5em;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
cowboy coder needs some help from SO-veterans: I have a given application that uses
I have code examples from some of my previous work that help me to
I could use some help with a RIA services query that I have been
I managed to get some help from a previous question and I have the
Can I have some help in improving this linq. I'm basically returning speakers from
Recently I have been looking at jquery/javascript solutions to emulating the placeholder attribute, but
I have been working on a project that dynamically creates a javascript file using
Yes i have been through the other questions that are related to this, but
Good morning! I would like to ask some help from you guys on how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.