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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:57:27+00:00 2026-05-24T07:57:27+00:00

On my website I have various containers with content <div> s text in them.

  • 0

On my website I have various containers with content <div>s text in them. I then have links in the container which change the content <div>s.

However, I cannot get the links to target a specific content , instead the both sets of links change both container <div>s.

http://jsfiddle.net/hKMFb/1/

If you look at the jfiddle, I want both the first-div and the second-div to have content in them automatically, and then I would like the links to only change their respective content. Instead I only have content1-4 showing up in both. I’ll put the code here as well:

//HTML
<div class="container-div">
    <div id="tab">
    <ul>
        <li id="tab1" class="active"><a href="#">Link 1</a></li>
        <li id="tab2"><a href="#">Link 2</a></li>
        <li id="tab3"><a href="#">Link 3</a></li>
        <li id="tab4"><a href="#">Link 4</a></li>
    </ul>
    </div>

    <div id="content1" class="content">Content Here1</div>
    <div id="content2" class="content">Content Here2</div>
    <div id="content3" class="content">Content Here3</div>
    <div id="content4" class="content">Content Here4</div>
</div>


<div class="container-div">
    <div id="tab">
    <ul>
        <li id="tab5" class="active"><a href="#">Link 5</a></li>
        <li id="tab6"><a href="#">Link 6</a></li>
        <li id="tab7"><a href="#">Link 7</a></li>
        <li id="tab8"><a href="#">Link 8</a></li>
    </ul>
    </div>
    <div id="content5" class="content">Content Here1</div>
    <div id="content6" class="content">Content Here2</div>
    <div id="content7" class="content">Content Here3</div>
    <div id="content8" class="content">Content Here4</div>
</div>

And the script:

//Jquery Business

$(document).ready(function() {
    var activeId = $(".active").attr("id").replace("tab",""); $("#content" + activeId).show();
   $("#tab a").click(function() {
      $(".content").hide();
      $("#tab .active").removeClass("active");
      $(this).addClass("active")
      var id = $(this).closest("li").attr("id").replace("tab","");
      $("#content" + id).show();
   });

});
  • 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-24T07:57:28+00:00Added an answer on May 24, 2026 at 7:57 am

    Is that you are looking for?

    http://jsfiddle.net/hKMFb/24/

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

Sidebar

Related Questions

I have a model for a multilingual website with wiki functionality which contains various
I have a solution which contains a website and various class libraries. The exists
I cannot open an existing website in MonoDevelop. I have tried various options with
I want to create a website with various users. The users can have different
I have website, usually all looks fine but sometimes one div is on the
I have website on the server, which is not precompiled (with source code, so
I have a website which i run localy and the path on the browser
I have various user controls that get placed in a content control within my
I have various simple ASP.NET MVC views for CRUD operations which work fine on
I have various sections on my website, such as a blog, forum, wiki etc

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.