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 8648209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:15:39+00:00 2026-06-12T13:15:39+00:00

I have a script I’m using to rotate images in an un-ordered list (LI).

  • 0

I have a script I’m using to rotate images in an un-ordered list (LI). The script works fine if there is one single instance of the referenced class on the page. However, if I have 2 instances of the rotating component, the second instance does not respond.

I think the solution is making the script continue to run until the second rotator gets it, but I’m not sure. I’ve tried a couple modifications with no luck. The current script is below:

function theRotator() {
    //Set the opacity of all images to 0
    $('div.rotator ul li').css({opacity: 0.0});

    // Remove images that only show in main-content
    $('div.rotator ul li.page-only').remove();

    //Get the first image and display it (gets set to full opacity)
    $('div.rotator ul li:first').css({opacity: 1.0});

    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('rotate()',4000);
}

function rotate() { 
    //Get the first image
    var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.rotator ul li:first');

    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));

    //Un-comment the 3 lines below to get the images in random order

    //var sibs = current.siblings();
    //var rndNum = Math.floor(Math.random() * sibs.length );
    //var next = $( sibs[ rndNum ] );


    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({opacity: 0.0})
    .addClass('show')
    .animate({opacity: 1.0}, 500);

    //Hide the current image
    current.animate({opacity: 0.0}, 1000)
    .removeClass('show');

};
setTimeout(function(){
    $(document).ready(function() {      
        //Load the slideshow
        theRotator();
        $('div.rotator').fadeIn(500);
        $('div.rotator ul li').fadeIn(500); // tweek for IE
    });
}, 500);
  • 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-12T13:15:40+00:00Added an answer on June 12, 2026 at 1:15 pm

    You probably need to replace :first in your selectors with :first-child. :first acts like .first() and selects only one element, while :first-child behaves like its CSS equivalent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have script that add water mark (PNG, transparent) to image(JPG). Works fine with
I have script file Get-ProcesWithParam.ps1 as param( $name ) function List-Process($name) { Write-Host Process
I have script with defined class (for instance, Singleton.php). This class implements classic singleton
I have script I am using here: http://jsfiddle.net/6b2yy/1/ It's supposed to change the background
I have script file which replaces one word with other in files . this
Possible Duplicate: one variable row inside another variable row I have script something like
I have a script that appends some rows to a table. One of the
I have a script that checks responses from HTTP servers using the PEAR HTTP
I have script that gets some data using DBI's fetchall_hashref(). Usually it returns a
I have script which calls zoho api, Its working fine on localhost but when

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.