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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:59:15+00:00 2026-06-09T03:59:15+00:00

Hello and let me first explain that I have not used jQuery very much

  • 0

Hello and let me first explain that I have not used jQuery very much at all. Simple show and hide and basic UI is the extent. So with that said, I am trying to be able to show a div, that is actually a “page” that has been linked to a “link”.

Markup:

<body>
<!--Footer and Navigation Div's-->
<div id="bg"><img src="images/bg.jpg" alt=""></div>
    <div id="footer">
        <p>S.E. <span>yoga</span></p>
            <div id="nav">
                <ul><a href="#">Link 1</a></ul>
                <ul><a href="#">Link 2</a></ul>
                <ul><a href="#">Link 3</a></ul>
                <ul><a href="#">Link 4</a></ul>
            </div>
    </div>
<!--END Footer and Navigation Div's-->

<div class="parent">
<div class="a">
        <p>this is a</p>
    </div>   
   <div class="b">
        <p>this is b</p>
    </div>
    <div class="c">
        <p>this is c</p>
    </div>
    <div class="d">
        <p>this is d</p>
    </div>
</body>
</html>

jQuery:

 /*
 $(document).ready(function(){
 $('#nav').click(function(){
        $(".a").slideToggle();
  var divname= this.value;
          $("#"+divname).show("slow").siblings().hide("slow");

    });
});*/ 

    $(document).ready(function(){
    $('.a, .b, .c, .d').hide();
});;

So the first script (commented out) I was using I was going to use as a starting point. The second script, where they are all hidden is where I was going to go from. Hide them all, then show only one at a time.

The divs are overlapping. Any help? 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-09T03:59:17+00:00Added an answer on June 9, 2026 at 3:59 am

    You can use this

     $(document).ready(function(){
             $('.parent  div').hide(); // hide div's on load using parent class as a starting point     
             $('#nav a').click(function() {  // on the anchor clicks that are inside div with id=nav
                var $div = $('.parent div').eq($(this).index('#nav a'));  // get the relevant div
                $div.show();  // show the relevant div
                $('.parent div').not($div).hide();  // hide all but the relevant div
            });​
        }):
    

    EDIT:

    $('.parent div') // <– this gets all divs under the element with class parent

    .eq(index) // will get the element at the given index which is the following

    $(this) // <– Current clicked anchor tag

    .index('#nav a'); // <– get the index() of the current anchor tags compared to other other anchor tags

    weird thing is I usually use $(this).index() and it works but this time it didn’t so I had to specify a selector inside the index.

    also fix your html to look like this instead

     <div id="nav">
        <ul>
            <li><a href="#">Link 1</a></li>
            <li><a href="#">Link 2</a></li>
            <li><a href="#">Link 3</a></li>
            <li><a href="#">Link 4</a></li>
        </ul>
    </div>
    

    Updated fiddle

    http://jsfiddle.net/HpCWW/1/

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

Sidebar

Related Questions

Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
Let's say that I have this string: s = '<p>Hello!</p>' When I pass this
Let's say I have: <input type=text id=first attribute1=test attribute2=hello attribute3=happy> <input type=text id=first attribute1=test
First off, let me start off that I am not a .net developer. The
First of all I have to apologize for my poor English, Please let me
I have the following problem. Let's take the input (wikitext) ======hello((my first program)) world======
I'm trying to make a simple PyQT4 application that will let me show the
Let's say I have this string: Hello &, how are you? I'm fine! Is
Let's say I have a string Hello and a list words = ['hello', 'Hallo',
Let's assume I have the string NSString* myString = @Hello,; How can I remove

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.