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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:44:03+00:00 2026-06-15T22:44:03+00:00

Hi i need to switch between div tags, I have no idea where’s the

  • 0

Hi i need to switch between div tags, I have no idea where’s the problem…
The site is XHTML strict…

$(document).ready(function() {

    var activeId = $(".active").each(function(){
       $("#content" + $(this).attr("id").replace("tab","")).show();
    });

    $(".tabs a").click(function() {
        var $tabs =$(this).closest(".tabs"); 
        $("#content" +$tabs.attr("data-lastContent")).hide();
        $(this).closest(".tabs").find(".active").removeClass("active");
        $(this).addClass("active")
        var id = $(this).closest("li").attr("id").replace("tab","");
        $tabs.attr("data-lastContent", id);
        $("#content" + id).show();
    });

});​

It is a menu and some divs below I need to switch… I use the code from this post http://jsfiddle.net/hKMFb/24/ but with no success….

<div class="tabs" data-lastContent="1">
<li id="tab1" class="active"><a href="#">PROSBA</a></li>
<li id="tab2"><a href="#">PRŮVODNÍ TEXT</a></li>
<li id="tab3"><a href="#">GALERIE</a></li>
<li id="tab4"><a href="#">JAK POMOCI?</a></li>
</div>
<div id="content1" class="content"><div class="scroller">ahojjjj</div></div>
<div id="content2" class="content"><div class="scroller">nee</div></div>
<div id="content3" class="content"><div class="scroller">ahdad</div></div>
<div id="content4" class="content"><div class="scroller">ahod</div></div>

Any input is appreciated.

Thanks.
Jan

  • 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-15T22:44:05+00:00Added an answer on June 15, 2026 at 10:44 pm

    Using the basics…DEMO

    JS:

    $(function(){
       $('.content').hide(); //hide all the contents
       $('.active').show();  //show only active
        $('.tab').click(function(event){
            event.preventDefault(); //stop from linking
        $('.content').hide(); //hide all the contents
        $('.selected').removeClass('selected'); //remove class from current tab
        $('.active').removeClass('active'); //remove class from current content
        var id = $(this).attr('href'); //get desired content id
        $(this).addClass('selected'); //add class to clicked tab
        $('#'+id).addClass('active').show(); //add class to active content and display
        });    
    
    });
    ​
    

    HTML:

    <ul>
        <li><a href="content1" class="tab selected">Tab1</a></li>
        <li><a href="content2" class="tab">Tab2</a></li>
        <li><a href="content3" class="tab">Tab3</a></li>
        <li><a href="content4" class="tab">Tab4</a></li>
    </ul>
    <div id="display">
        <div id="content1" class="content active">blah</div>    
        <div id="content2" class="content">blahh</div>
        <div id="content3" class="content">blahhh</div>
        <div id="content4" class="content">blahhhh</div>
    </div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    CSS:

    .selected { color: #933; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 threads. I need to switch between them by pressing a key.
I'm developing ios 6 application and need to switch between 2 views. I've done
i need to switch between two variables so i am able to serve two
I need to switch between some databases at the same time (using VB.net). As
In my project i need to switch between databases during runtime. I tried to
I recently wanted/thought I need a form with two child forms to switch between
I need to switch between the short and the full description of an article.
can i switch between my two network cards,i need to use on card to
I need to find a way to switch between four text inputs. Example Usage:
I have an iPad application which has many categorized images I need to switch

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.