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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:09:14+00:00 2026-06-14T23:09:14+00:00

Im trying to add a simple class/id on my <li> element which is in

  • 0

Im trying to add a simple class/id on my <li> element which is in my menu, by using jquery.

However, when I click on a menu-option my class/id is added by jquery successfully but my site of course is gonna update because it redirects to the choicen site.

The result I end up with is that my class/id is removed because of this update..

How can I bypass this so my class/id stays on the selected menu <li> element.

My code looks like this:

 $(document).ready(function()  
 {  
    $('li').click(function()  
    {  
       $(this).addClass('selected');  
    });  
 });

This is the site: http://insatsplutonen.xedge.nu/
Click yourself thru the menu-options. If you click on ex: Blogg the class ‘selected will be added on the <li> element but will disappear because of page-load…

Thing is i want selected menu-option to turn white and others stay gray 🙂

Kind regards /Haris

  • 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-14T23:09:16+00:00Added an answer on June 14, 2026 at 11:09 pm

    It seems like you are loading the page based on the query string. When I select “Blogg”, I get http://insatsplutonen.xedge.nu/?Blogg

    When you load the page and check your query string and find a menu variable there, set a variable to the menu item value, and use it to set the class for the menu item accordingly. Ex. for Blogg item:

    <li <?php echo ($queryStrVal == 'Blogg') ? 'class="selected"' : ''; ?>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a simple answer, but I'm trying to add a dom-created element
I'm using Magento Community Edition ver. 1.6.2.0. I’m trying to add a Simple product
I'm currently trying to implement a simple Add-In for InfoPath 2010 Filler/Editor mode, which
I am trying to add an attribute using javax.xml.bind.annotation to a simple type (String
I am trying to write simple Binary Search tree class (BST). When I add
I'm trying to add simple login page to ASP.NET MVC app. I actually use
I am trying to add a simple log in with Facebook button to my
I am trying to add a simple form to allow my users to edit
I'm trying to add some simple peer-to-peer connection functionality to an iOS library. Coding
I'm trying to create a simple Add-On for SQL Server 2008; it is simply

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.