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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:49:52+00:00 2026-05-16T02:49:52+00:00

Hey folks. I am using a little bit of jQuery to do a live

  • 0

Hey folks. I am using a little bit of jQuery to do a live sort of my portfolio when various categories are selected. Basically, the script matches the content of an <li> tag on click (my menu) with the class names of other <li> tags elsewhere on the page. The result is the portfolio items match the nav clicked will show and hide the rest. A live sort. However, i want to add the ability to add a permalink to activate the jquery to sort by a hashtag at the end.. for example: work.html#category1 would automatically set the script to hide everything but category one. My script and basic page setup is below. Any help would be greatly appreciated!

 <script>
    $(document).ready(function() {
        $('#worknavwrap p a').click(function() {
            $(this).css('outline','none');
            $('ul#worknavwrap .current').removeClass('current');
            $(this).parent().addClass('current');

            var filterVal = $(this).text().toLowerCase().replace(' ','_');

            if(filterVal == 'all') {
                $('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
            } else {

                $('ul#portfolio li').each(function() {
                    if(!$(this).hasClass(filterVal)) {
                        $(this).fadeOut('normal').addClass('hidden');
                    } else {
                        $(this).fadeIn('slow').removeClass('hidden');
                    }
                });
            }

            return false;
        });
    });
    </script>
    <ul id="worknavwrap">
      <li><a href="#category1">Category 1</a></li>
      <li><a href="#category2">Category 2</a></li>
      <li><a href="#category3">Category 3</a></li>
    </ul>
    <ul id="portfolio">
      <li class="category1">Item 1</li>
      <li class="category1">Item 2</li>
      <li class="category2">Item 3</li>
      <li class="category1">Item 4</li>
      <li class="category3">Item 5</li>
      <li class="category3">Item 6</li>
      <li class="category2">Item 7</li>
      <li class="category1">Item 8</li>
    </ul>
  • 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-16T02:49:52+00:00Added an answer on May 16, 2026 at 2:49 am

    Do this:

    if(window.location.hash) {
        $('#worknavwrap a[href=' + window.location.hash + ']').click();
    }
    

    It will find the <a> element that has the href attribute matching the hash, and trigger its .click() handler.

    Even better would be to provide ID attributes for the <a> elements like:

    <ul id="worknavwrap">
        <li><a id="category1" href="#category1">Category 1</a></li>
        <li><a id="category2" href="#category2">Category 2</a></li>
        <li><a id="category3" href="#category3">Category 3</a></li>
    </ul>
    

    So then you could just do:

    if(window.location.hash) {
        $(window.location.hash).click();
    }
    

    By the way, for your code to match your HTML, you need:

    $('#worknavwrap li a').click(function() {...
    

    instead of:

    $('#worknavwrap p a').click(function() {...
    

    and also:

    var filterVal = $(this).text().toLowerCase().replace(' ','');
    

    instead of:

    var filterVal = $(this).text().toLowerCase().replace(' ','_');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey folks... I am back with another issue... I am using jquery Autocomplete on
Hey folks I am trying to implement a search functionality in a website using
Hey folks..!! I m using styleManager.setStyleDeclaration to set the CssStyleDeclaration object for more then
Hey Folks, I have a tree and using proper fields and variables, I want
Hey folks, I'm pretty new to flash, so maybe I'm missing something. I'm using
Hey folks, diving into jQuery and loving it. I have a set of links
Hey folks, sorry this is a bit of a longer question... I have a
hey folks I'm having a bit of an issue trying to deploy my rails
Hey folks, I am trying to import a database (.sql) file using phpmy admin
Problem Hey folks. I'm looking for some advice on python performance. Some background on

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.