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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:29:51+00:00 2026-06-17T05:29:51+00:00

* EDIT: Here’s a link to a staging version of the site: http://staging-site.site44.com/ *

  • 0

*EDIT: Here’s a link to a staging version of the site: http://staging-site.site44.com/ *

I am extremely new to jquery so I apologize if this question is extremely simple. What I’m trying to do on my website is first when the page is loaded have the content in my #topContent div fade in.

But along with this I’d also like my main navigation to use jquery hashtags to switch up the page content displayed in the #topContent div. I’ve read up a bit on how to do this in jquery and from what I’ve read I think I need create page sections within my main html doc that are hidden until a certain nav link is selected – then hide the content that is currently showing and show the content associated with the nav link that was just selected, how close am I?

Here’s my attempt so far at doing this…

HTML

<nav id="headerNav">

            <ul class="navList">
                <li class="navItem"><a href="#products" class="transition">Products</a></li>
                <li id="view-about" class="navItem"><a href="#about" class="transition">About</a></li>
                <li class="navItem"><a href="#portfolio">Portfolio</a></li>
                <li class="navItem"><a href="#">Contact</a></li>
            </ul>
        </nav>


    </div>

</div>

<!-- topMain -->
<div id="topContentWrapper">

    <div id="topContent">



            <div id="#products">
                <h2>Test worked! - products </h2>
                <p>this test just worked sooo hard!</p> 
            </div>


            <div id="#about">
                <h2>Test worked! - about </h2>
                <p>this test just worked sooo hard!</p> 
            </div>


            <div id="#portfolio">
                <h2>Test worked! - Portfolio </h2>
                <p>this test just worked sooo hard!</p> 
            </div>



    </div>




</div>

JS

// Fade In Effect

$(document).ready(function() {
    $("#topContent").css("display", "none");
    $("#topContent").fadeIn(2000);

$("a.transition").click(function(event){
    event.preventDefault();
    linkLocation = this.href;
    $("#topContent").fadeOut(1000);      
});

function redirectPage() {
    window.location = linkLocation;
}

$("#view-about").click(function(event){
    $("#products").fadeOut(1000);
    $("#portfolio").fadeOut(1000);   
    $("#about").fadeIn(1000); 
});

});
  • 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-17T05:29:52+00:00Added an answer on June 17, 2026 at 5:29 am

    Ok, this code should work:

    $(function(){
        $last = null;
        $(".navList li a").click(function(){
            if ($last != null) $last.fadeOut(1000);
            $last = $($(this).attr("href"));
            $($(this).attr("href")).fadeIn(2000);
        });
    });
    

    However, you will need to change your topContent to this:

        <div id="topContent">
    
    
    
                <div id="products" style="display: none;">
                    <h2>Test worked! - products </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
                <div id="about" style="display: none;">
                    <h2>Test worked! - about </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
                <div id="portfolio" style="display: none;">
                    <h2>Test worked! - Portfolio </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
    
        </div>
    

    Reasons:

    Firstly, you need your ids to be like this: id="about" and not this: id="#about".
    The id specified doesn’t need a # in front of it. (Same as how class doesn’t need a . when setting a tag with it)

    The jQuery code I tested locally, so it should work.

    Note:

    You may want to automatically have some different content automatically displayed, because right now as it loads it is blank until you click one of the links.

    Hope this helped!

    Edit:

    I suggest you change the code to this:

    ids =   [ "products", "about", "portfolio" ];
    links = [ "Products", "About", "Portfolio" ];
    
    $(function(){
        $last = null;
        $(".navList li a").click(function(){
            New = "#" + ids[links.indexOf($(this).text())];
            if ($last != null) $last.fadeOut(1000);
            $last = $(New);
            $(New).fadeIn(2000);
        });
    });
    

    Because it will keep all the content constantly in the same place. For this to work, you’ll need to change two more sections of your code:

    <ul class="navList">
        <li class="navItem"><a href="#topContent" class="transition">Products</a></li>
        <li id="view-about" class="navItem"><a href="#topContent" class="transition">About</a></li>
        <li class="navItem"><a href="#topContent">Portfolio</a></li>
        <li class="navItem"><a href="#topContent">Contact</a></li>
    </ul>
    

    And:

        <div id="topContent">
    
    
    
                <div id="products" style="display: none; position: absolute">
                    <h2>Test worked! - products </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
                <div id="about" style="display: none; position: absolute">
                    <h2>Test worked! - about </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
                <div id="portfolio" style="display: none; position: absolute">
                    <h2>Test worked! - Portfolio </h2>
                    <p>this test just worked sooo hard!</p> 
                </div>
    
    
    
        </div>
    

    That last part was just my suggestion, but do whatever you need to.

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

Sidebar

Related Questions

EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
[EDIT: Here's a link to a mockup of what I'm trying to create] http://i53.tinypic.com/w9v2np.jpg
EDIT: Here's a link to show you my sample code: http://www.singingeels.com/jqtest/ I have a
http://jsbin.com/uxafu3/14/edit Here is a link showing what seems to be a bug in the
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: Here is the new code: $(#normalcontent).hide(fast).load($this.attr(href) + #normalcontent,,function(){ $(this).slideDown(normal); $(this).find(img).each(function(){ if($(this).hasClass(large)) { var
http://jsbin.com/uxepap/3/edit Here is div with links inside. I'm trying to replace comma inside last
Edit - here are some resources in response to comments: costate: http://bamafolks.com/randy/students/embedded/dynamicC_mtask.html writeUserBlockArray: http://ftp1.digi.com/support/documentation/html/DynCFunctionReference/12fun595.htm#1259708
http://jsbin.com/aboca3/95/edit Here is working example for separate numeral and alphabetical sort. It works well,
When a user links to link it redirects to edit.php - here's an example:

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.