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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:32:22+00:00 2026-06-07T11:32:22+00:00

I am making a one-page website for a client. There are 3 different menu

  • 0

I am making a one-page website for a client. There are 3 different menu groups, but in this example i simplified it to one menu and less content.

I have this navigation:

    <nav>
        <ul id="main" class="toggle">
            <li><a id="design" href="#">DESIGN</a></li>
            <li><a id="contactus" href="#">CONTACT US</a></li>
            <li><a id="aboutus" href="#">ABOUT US</a></li>
            <li><a id="news" href="#">NEWS</a></li>
        </ul>
    </nav>

And Divs like that below:

<div class="designcontent">
Design Content Here
</div>
<div class="aboutuscontent">
About us Content Here      
</div>

So if i were to click on DESIGN it would show designcontent, and then if i were to click ABOUT US it would show aboutuscontent and so on.

I am asking for a short-hand code of

        $("#design").click(function(){
        $('.homecontent').fadeOut(500);
        $('.designcontent').delay(500).fadeIn(1000);
        return false;
        });

        $("#home").click(function(){
        $('.designcontent').fadeOut(500);
        $('.homecontent').delay(500).fadeIn(1000);
        return false;
        }); 

Because it gets more and more complicated if there are many pages, and if my client wants to add a new page.

I have this jQuery code below to get id’s and use them in Array and hide the contents on load:

$('#main li a').each(function(){
  liIds.push('.'+ $(this).attr('id')+'content');
  $(''+liIds).hide();   
})

What i am missing is, clicking on menu links and showing the correct content each time a menu is clicked.

I hope my question is clear enough, if not i can provide visual examples on jsFiddle.

Thanks for taking time to read my question

My problem is solved using:

$("a").click(function(){
    var cls = $(this).attr('id')
     $('.' + cls + 'content').addClass('onpage');
    $('.onpage').fadeOut(500);
    $('.' + cls + 'content').delay(500).fadeIn(1000);
    return false;
})
  • 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-07T11:32:25+00:00Added an answer on June 7, 2026 at 11:32 am

    you can use similar name for id of the anchor and it’s target element’s class:

    html:

    <li><a id="design" href="#">DESIGN</a></li> 
    
    <div class="design content">
       Design Content Here
    </div>
    

    js:

    $("ul li a").click(function(){
        var cls = $(this).attr('id')
        $(".content").fadeOut(500);
        $('.' + cls).delay(500).fadeIn(1000);
        return false;
    })
    

    DEMO

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

Sidebar

Related Questions

I'm making a website that tend to handle all the request in one page
I am currently building an making my new website. It uses one page and
I am making a website where there are different types of items such as
I'making website which is for all desktop/iPad/iPhone. In one page I have header and
Is there any standards/guidelines/good practices for making websites with support of different content and
I'm making a web-app with PhoneGap. Here's my current hurdle: On page one, the
I'm making a single page application, and one approach I am considering is keeping
I'm making a wordpress theme options page, and one of the options I want
I was making one table that have two foreign key to another tables. But
I'm making a new website. It will be blog style, but made from scratch

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.