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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:36:05+00:00 2026-05-12T23:36:05+00:00

I am pretty new to JQuery and I’m working on a menu based on

  • 0

I am pretty new to JQuery and I’m working on a menu based on Superfish script.
I am having troubles to keep the addClass on current clicked item set when I navigate thru links.

My code:

JS

<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){

jQuery("ul.sf-menu").superfish({pathClass:  'corrente'});            

jQuery('#sf-menu li a').click(function() {
      jQuery("#sf-menu li").removeClass('corrente');
      jQuery(this).parents().filter("li").addClass('corrente');
      jQuery("ul.sf-menu").superfish({pathClass:  'corrente'    });
});
});
</script> 

HTML

<ul id="sf-menu" class="sf-menu sf-navbar">
  <li><a href="#">Home</a></li>
  <li><a href="#">Band</a></li>
  <li><a href="#">Solo Projects</a>
      <ul>
      <li><a href="#">Tim</a></li>
      <li><a href="#">Tom</a></li>
      <li><a href="#">John</a></li>
      </ul>
  </li>
  <li><a href="#">Media Appearances</a></li>
  <li><a href="#">Tour</a>
      <ul>
     <li><a href="#">The Reunion Tour</a>
         <ul>
        <li><a href="#">North American Leg</a></li>
     </ul>
         </li>
      </ul>
  </li>
  <li><a href="#">Gallery</a></li>
</ul>

The above html works fine, the class “corrente” is correctly set, but when I change html inserting actual links, the class is set fine but get lost when the destination page is loaded.

Can you please give me any advice on how store the class added and pass it thru the destination page?

Thank you in advance

  • 1 1 Answer
  • 1 View
  • 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-12T23:36:05+00:00Added an answer on May 12, 2026 at 11:36 pm

    The entire Javascript environment resets when you go to a new page, so you can’t keep changes made in javascript between pages.

    Possible ways to deal with this:

    1. open the new page in an iframe or
      in a separate window. The outer
      page (for an iframe) or the original
      page (for a separate window) doesn’t
      reload, so javascript changes in it
      will not be lost.
    2. Add some sort of querystring to the url when you
      pass to the new page, and then
      interpret that querystring in the
      new page (within javascript) to make
      whatever change you’ve made again.
    3. Put data in a cookie that will allow you to apply the change on the new page.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty new to jquery and having a bit of a problem with a function
So I am pretty new to JQuery and just spent 5 hours getting this
im pretty new to jQuery, and i dont know how to do that, and
I'm pretty new to jQuery, so please forgive... I have a page with a
I'm pretty new to jQuery-UI, but I love what I see so far. I
So I am pretty new to jQuery and Javascript in Gen. I like the
i am pretty new to jquery and hope this is the right place to
I'm pretty new to jQuery (and javascript for that matter), so this is probably
i'm pretty new to jquery. I'm trying to insert an element to the DOM,
I'm pretty new to jquery so I'm proud of myself for what I've figured

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.