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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:32:26+00:00 2026-06-18T08:32:26+00:00

I’m working on a website that’s implementing tabs via javascript, and I’d like to

  • 0

I’m working on a website that’s implementing tabs via javascript, and I’d like to create a button that goes to the ‘next’ tab. I don’t care if I have to hardcode in the tab IDs into the javascript or what, but regardless I’d like to be able to advance the tabs.

EDIT3: Here’s a jfiddle implementation of what I have. I just want the next button to be able to advance the tabs similar to clicking on them. Thanks!

http://jsfiddle.net/Cd5qb/

Here’s the code I have for the current working tabs, without a button:

var tabContents = $(".tab_content").hide(), 
    tabs = $("ul.tabs li");

tabs.first().addClass("active").show();
tabContents.first().show();

tabs.click(function() {
    var $this = $(this), 
        activeTab = $this.find('a').attr('href');
    if(!$this.hasClass('active')){
        $this.addClass('active').siblings().removeClass('active');
        tabContents.hide().filter(activeTab).fadeIn();
    }
    return false;
}); 

So I’m trying to implement something similar to the tabs.click for a button, and here’s what I’ve got so far:

var tabbtn = $(".tabbutton");
tabbtn.click(function() {
    var listItem = document.getElementById('tab2');
    var $this = $(this), 
        activeTab = $this.find('a').attr('href');
    tabContents.hide().filter("#tab2").fadeIn();

    return false;
});

This will actually display the right tab’s information, but it won’t change which tab header is highlighted.

Anyone have any ideas? Thanks in advance for the help!

  • 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-18T08:32:27+00:00Added an answer on June 18, 2026 at 8:32 am

    How about:

    $(".tabbutton").click(function(){
        var nextTab = parseInt($("li.active").attr("id"), 10) + 1;
        if(nextTab === 4){ nextTab = 1; }
        $("#"+nextTab).click();
    });
    

    and adding a numerical equivalent id to the li items?

    Working fiddle is here: http://jsfiddle.net/gugahoi/Cd5qb/1/

    UPDATE:

    Ok, here is the new fiddle with only the button changing the tabs.

    This is all the js:

    var tabContents = $(".tab_content").hide(), 
        tabs = $("ul.tabs li");
    
    tabs.first().addClass("active").show();
    tabContents.first().show();
    
    $(".tabbutton").click(function(){
        var nextTab = parseInt($("li.active").attr("id"), 10) + 1;
        if(nextTab === 4){ nextTab = 1; }
        tabs.removeClass("active");
        $("#"+nextTab).addClass("active");
        tabContents.hide();
        $("#tab"+nextTab).fadeIn("slow");
    });
    

    And this is the only update needed in the html:

    <ul class="tabs clearfix">
        <li id="1"><a href="#">Tab1</a></li>
        <li id="2"><a href="#">Tab2</a></li>
        <li id="3"><a href="#">Tab3</a></li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.