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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:45:37+00:00 2026-05-25T19:45:37+00:00

i have a simple slideshow which is working okay so far. it consists of

  • 0

i have a simple slideshow which is working okay so far. it consists of a pager and the images to display. both are an unordered list:

<ul id="keyvisualpager">
    <li><a><span>Show Keyvisual 1</span></a></li>
    <li><a><span>Show Keyvisual 2</span></a></li>
    <li><a><span>Show Keyvisual 3</span></a></li>               
</ul>

<ul id="keyvisualslides">
    <li><img src="index_files/mbr_keyvisual1.jpg" alt="Keyvisual" /></li>
    <li><img src="index_files/mbr_keyvisual2.jpg" alt="Keyvisual" /></li>
    <li><img src="index_files/mbr_keyvisual3.jpg" alt="Keyvisual" /></li>
</ul>

The according jQuery code is:

$('#keyvisualpager li a').click(function () { 

    // get position of a element
    var mbr_index = $(this).parent().prevAll().length;
    var mbr_targetkeyvisual = mbr_index + 1;

    // hide current image and show the target image
    $('#keyvisualslides li:visible').hide();        
    $('#keyvisualslides li:nth-child('+mbr_targetkeyvisual+')').show()

    // remove active class from current indicator and add the same class to target indicator
    $('#keyvisualpager li a').removeClass('keyvisualactive');
    $('#keyvisualpager li:nth-child('+mbr_targetkeyvisual+') a').addClass('keyvisualactive');

});

initially all images are set to display: none; … upcon clicking a a link in #keyvisualpager the according image is then displayed. at the same time the indicator changes accordingly.

now, my problem:

apart from this mode of navigating through the images i need the whole slideshow to automatically advance. how can i achieve that:

a) the next image is shown after lets say 5 seconds and

b) the class “.keyvisualactive” is added to the according a element in #keyvisualpager

note: unfortunately i have to use jquery 1.2.1, updating is not an option.

thanks for your help guys

EDIT

i am now using this code. it almost works. but after the last image in the set is displayed: how can i tell it to start over with the first image? thanks!

var reload = setInterval(function(){
    // get position of a element
    var mbr_index = $('#keyvisualpager li .keyvisualactive').parent().prevAll().length;
    var mbr_targetkeyvisual = mbr_index + 2;
    // alert(mbr_index+'//'+mbr_targetkeyvisual)

    // hide current image and show the target image
    $('#keyvisualslides li:visible').hide();        
    $('#keyvisualslides li:nth-child('+mbr_targetkeyvisual+')').show();

    // remove active class from current indicator and add the same class to target indicator
    $('#keyvisualpager li a').removeClass('keyvisualactive');
    $('#keyvisualpager li:nth-child('+mbr_targetkeyvisual+') a').addClass('keyvisualactive');

}, 2000);
  • 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-05-25T19:45:38+00:00Added an answer on May 25, 2026 at 7:45 pm

    You can use JavaScript’s setInterval() method to achieve this.

    var reload = setInterval(function(){
                // do something
    }, 5000);
    

    The number is length of every pause in milliseconds.

    To stop the slideshow, for example when a user selects an image, you can use clearInterval() method.

    EDIT

    Try something like this:

    $('#keyvisualpager li a').click(function () {
    
        var reload = setInterval(function(){
    
            // get position of a element
            var mbr_index = $(this).parent().prevAll().length;
            var mbr_targetkeyvisual = mbr_index + 1;
    
            // hide current image and show the target image
            $('#keyvisualslides li:visible').hide();        
            $('#keyvisualslides li:nth-child('+mbr_targetkeyvisual+')').show()
    
            // remove active class from current indicator and add the same class to target indicator
            $('#keyvisualpager li a').removeClass('keyvisualactive');
            $('#keyvisualpager li:nth-child('+mbr_targetkeyvisual+') a').addClass('keyvisualactive');
    
        }, 5000);
    
        $('#pagerstop').click(function(){
            clearInterval(reload);
        }
    
    });
    

    EDIT 2

    You have to keep track of image count and the index you are at (if I understood correctly you have this in your var mbr_targetkeyvisual?) so it should work like this (not tested):

    // Image count
    var content_length = $('#keyvisualslides').children().length;
    
    var automate = setInterval(function(){
        if(index < content_length){
            $('#keyvisualslides li:visible').hide();        
            $('#keyvisualslides li:nth-child('+mbr_targetkeyvisual+')').show();
            mbr_targetkeyvisual++;
        }
        else{
            mbr_targetkeyvisual = 0;
            $('#keyvisualslides li:visible').hide();
            $('#keyvisualslides li:nth-child('+mbr_targetkeyvisual+')').show();
            mbr_targetkeyvisual++;
        }
    }, 5000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple slideshow which automatticlly changes the image using setInterval every 5
I have a simple slideshow of images and use jQuery to fade out one
I have a bit of javascript/jQuery which creates a simple slideshow. I'm learning jquery
I have a very simple slideshow setup on my homepage with fading images using
I have a pretty simple image switcher, which I use for manual images switcher
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package in which On Error event handler I have created
I have a simple function that animates a bunch of images by crossfading them.
I am using a simple script that displays images in a jquery slideshow -
I have an application which behaves as a slideshow for all pictures in a

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.