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

  • Home
  • SEARCH
  • 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 7733209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:55:40+00:00 2026-06-01T06:55:40+00:00

I built a featured tabbing system (4 tabs) with jquery. It works manually but

  • 0

I built a featured tabbing system (4 tabs) with jquery. It works manually but I want to make it loop automatically, i.g. every 5 seconds. I can trigger each tab with the click even but I don’t know how to go back to the beginning from 1st tab once it reach the last tab.

The coding too long to past here, so I have made a jsfiddle link to it: http://jsfiddle.net/ZSPX3/

I just wanna iterate through each tab and click them each, then start from the beginning of the tab again, as in I want an infinite slideshow. But I’m stuck…

I don’t want any plugins, I wanna learn how to do this with my own hand, please.

Many thanks

  • 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-01T06:55:41+00:00Added an answer on June 1, 2026 at 6:55 am

    The key part here is to check the index of the currently-on tab and see if there’s any tabs beyond it. If not, revert to the first tab. So:

    HTML

    <ul id='tabs'>
        <li class='on'>tab 1</li>
        <li>tab 2</li>
        <li>tab 3</li>
        <li>tab 4</li>
        <li>tab 5</li>
    </ul>
    

    CSS

    #tabs { list-style: none; margin: 0; padding: 0; }
    #tabs li { float: left; background: #ddd; padding: 6px; }
    #tabs li.on { background: #f90; color: #fff; }
    

    JS (jQuery assumed)

    $(function() {
    
        //cache a reference to the tabs
        var tabs = $('#tabs li');
    
        //on click to tab, turn it on, and turn previously-on tab off
        tabs.click(function() { $(this).addClass('on').siblings('.on').removeClass('on'); });
    
        //auto-rotate every 5 seconds
        setInterval(function() {
    
                //get currently-on tab
            var onTab = tabs.filter('.on');
    
                //click either next tab, if exists, else first one
            var nextTab = onTab.index() < tabs.length-1 ? onTab.next() : tabs.first();
            nextTab.click();
        }, 5000);
    });
    

    We compare the (zero-indexed) index of the currently-on tab with the total number of tabs (-1, to account for the zero-indexing). If the former is lower than the latter, there’s still some tabs to go; if not, i.e. they’re equal, we’ve reached the end – go back to the start.

    Hope this helps.

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

Sidebar

Related Questions

I've got a slider that's built with jQuery UI Tabs : <section id=featured> <aside
I have an already built application and I want to add a feature that
I want to have unique object ids over whole database. Is there any built-in
Is there a built-in feature to make a Swing JButton audible. I am interested
I wonder there might be a built-in feature in Groovy, something like aCollection.doEachBulk(100) {
I'd like to use the built in directory security features built into the web.config
I've been playing with the .NET built in localization features and they seem to
We have customers who, for unassailable reasons, cannot use SQL Server's built-in backup features
Have just started using Visual Studio Professional's built-in unit testing features, which as I
This may be a build in feature of FMOD, but I'd like to see

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.