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

The Archive Base Latest Questions

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

I have this jQuery which shows/hides content depending on the list item that’s clicked.

  • 0

I have this jQuery which shows/hides content depending on the list item that’s clicked. I also want to be able to show specific content upon landing on this page, dependant on what link the user clicked on another page.

I know that to make this happen, I have to carry the variable over from the other link somehow, and make it act as the variable.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>    
<script type="text/javascript"> 
$(document).ready(function() {
$('#side_nav ul li a').click(function() {
    $('#side_nav ul li.current').removeClass('current');
    $(this).parent().addClass('current');

    var filterVal = $(this).attr('class');

        $('#content div.section').each(function() {
            if($(this).hasClass(filterVal)) {
                $(this).fadeIn(200);
            } else {
                $(this).hide();
            }
        });
    return false;
});
});
</script>

I’ve tried adding #desired_content to the end of the url at the link on the separate page and I know that using window.location.hash, I can pull that hash lable in as the variable somehow but I’m lost as to exactly how to accomplish that.

Please help.

EDIT: I added this to the external page:

<li><a href="./about.html#how_it_works">HOW IT WORKS</a></li>

and this to the target page, just to TEST whether the class being added

<script type="text/javascript"> 
$(document).ready(function() {
    var myHash = window.location.hash;

    if( myHash == "#how_it_works" ){
        $('#content div.how_it_works').addClass('test');
    }else if( myHash == "#option2" ){
        // fade in option2
    }


});     
</script>

I don’t understand why this isn’t working…

  • 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-17T08:20:52+00:00Added an answer on June 17, 2026 at 8:20 am

    Hash URLs have mostly been used for in-page anchor tags (back to top, etc) and so I’d suggest that directing someone to a certain section of your page using hash URLs makes a lot of sense.

    What I’ve done, once on the page, was grab the hash URL via window.location.hash and manipulate your page based on this string.

    var myHash = window.location.hash;
    
    if( myHash == "#desired_content" ){
    // fade in option1
    }else if( myHash == "#option2" ){
    // fade in option2
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this javascript code to which i want to add the jquery fade-in
I have found and customized this JQuery script, which displays different content when different
I have this jquery script which suppose to hide/show div element base on the
On my main page I have this jquery code which does an ajax call
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
We have this anonymous function in our code, which is part of the jQuery's
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have a jquery selector which looks like this: $(#MasterListDVWP tr td:contains(' + currentSchool
I have a jQuery menu which is build up by like this: <h3 id='300'
I have this jquery function that works, except I need to add something. I

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.