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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:57:15+00:00 2026-05-27T20:57:15+00:00

I have an accordion style navigation list set up so that when categories are

  • 0

I have an accordion style navigation list set up so that when categories are clicked it opens up to show sub-categories that link to pages.

What I would like to do is have the accordion navigation list keep it’s open or closed state when the new page opens.

I’ve gathered that cookies work to retain the state on refresh, but how do I retain the state when a different page is visited? All the pages have the same accordion navigation list.

  • 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-27T20:57:15+00:00Added an answer on May 27, 2026 at 8:57 pm

    I found a solution, it uses the accordian plug-in found here, http://www.i-marco.nl/weblog/archive/2010/02/27/yup_yet_another_jquery_accordi and the jquery cookie.js plug-in

    I added id’s to the header anchor tages in the HTNL mark-up like so,

     <li>
            <a id="m1" class="label" href="#">Sound/Audio Systems</a>
            <ul class="acitem">
                <li><a href="products.php?sub_cat=PA_Systems">PA Systems</a></li>
                <li><a href="#">Loudspeakers</a></li>
                <li><a href="#">Microphones </a></li>
                <li><a href="#">DJ Equipment</a></li>
                <li><a href="#">Sound Processing Equipment</a></li>
            </ul>
        </li>
    

    And modified the accordian.js code, I added the lines beginning with $.cookie, and the If statement in the document.ready funciton.

    jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand > .acitem', this).show();
        $('li.expand > .acitem', this).prev().addClass('active'),
        currentID = "";
        $('li a', this).click(
            function(e) {
                e.stopImmediatePropagation();
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if($(parent).hasClass('noaccordion')) {
                    if(theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal', function() {
                        if ($(this).is(':visible')) {
                            $(this).prev().addClass('active');
                            currentID = $(this).prev().attr('id');
                            $.cookie('menustate', currentID, {expires: 2, path: '/'});
                        }
                        else {
                            $(this).prev().removeClass('active');
                            $.cookie('menustate', null, {expires: 2, path: '/'});
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal', 
                            function() {
                                $(this).prev().removeClass('active');
                                $.cookie('menustate', null, {expires: 2, path: '/'});
                            }
                        );
                        return false;  
                    }
                    return false;
                }
                if(theElement.hasClass('acitem') && !theElement.is(':visible')) {         
                    $('.acitem:visible', parent).first().slideUp('normal', function() {
                        $(this).prev().removeClass('active');
                        $.cookie('menustate', null, {expires: 2, path: '/'});
                    });
                    theElement.slideDown('normal', function() {
                        $(this).prev().addClass('active');
                        currentID = $(this).prev().attr('id');
                        $.cookie('menustate', currentID, {expires: 2, path: '/'});
                        });
                        return false;
                    }
                }
            }
        );
    });
    
    };
    
    
    
    $(document).ready(function() {
    $('.menu').initMenu();$('#side-navigation_frame').show();
    if ($.cookie('menustate')) {
        var anchor = "",
            elementID = $.cookie('menustate');
        anchor = document.getElementById(elementID);
        $(anchor).addClass('active');
        $(anchor).next().show();
    
    }
    });
    

    It works nicely, not bad for a beginner, thanks for all the advise.

    Rob Fenwick

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

Sidebar

Related Questions

I have a jQuery based accordion style navigation that I am trying to modify.
I have a set of divs to show/hide content in a typical accordion style.
I have a jquery accordion style menu that I'd like to add some shortcut
I have an Accordion style of navigation section on a website at work and
i have done an Accordion style jQuery function which works lovely, but would like
I have to show some functionality similar to accordion that is of jquery so
I have a simple accordion type page containing a list of H3 headers and
I have a Jquery Accordion and I have a asp.net GridView below that. When
I have a jquery accordion that I want to use nth-child to assign odd
I have a vertical accordion which opens perfectly fine when starting to open the

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.