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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:19:56+00:00 2026-06-12T00:19:56+00:00

Im experimenting a bit with jquery and having a big problem which i have

  • 0

Im experimenting a bit with jquery and having a big problem which i have been trying to solve for the past day with google but not sure how to figure it out.

I use a index.php page with a simple php script to retrieve my content from a db, i use links like: index.php?title=about (example). I found a small jquery script that adds a class active to the <li> you click on, this works perfect if the url is (#about), it keeps the class active until other link is clicked. but if its an url like “index.php?title=about” its removes the active class.

This is my css / html and jquery, my question is how do i keep the button active when its being clicked.

    <style type="text/css"> 
    .nav li { list-style: none; cursor:pointer; }
    .nav li a { display: block; width: 279px; height: 30px;}
    .nav-home { background: url(img/home.png); width: 279px; height: 27px; }
    .nav-home.active, .nav-home:hover { background: url(img/home_1.png); width: 279px;          height: 27px;}
    .nav-video { background: url(img/video.png); width: 279px; height: 27px; }
    .nav-video.active, .nav-video:hover { background: url(img/video_1.png); width: 279px; height: 27px;}
    .nav-contact { background: url(img/contact.png); width: 279px; height: 27px; }
    .nav-contact.active, .nav-contact:hover { background: url(img/contact_1.png); width: 279px; height: 27px;}
    </style> 

html and jquery:

    <ul class="nav">
    <li class="nav-home"><a href="index.php?title=home"></a></li>
    <li class="nav-video"><a href="index.php?title=video"></a></li>
    <li class="nav-contact"><a href="index.php?title=contact"></a></li>
    </ul>
    <script type="text/javascript">
    $('.nav li').click( function() {
    $(this).addClass('active').siblings().removeClass('active');
    });
    </script>

Any help would be really appreciated, kinds regards

  • 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-12T00:19:57+00:00Added an answer on June 12, 2026 at 12:19 am

    If you load a new page, you won’t get track of previous client side interactions.

    You have to give the active class in php, or either parse current window.location, get the title value and select <li> element according to this.

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

Sidebar

Related Questions

I'm new to python and experimenting a bit but having trouble making a list
I have been experimenting a bit with Objective-C and noted some, at least to
I am a bit of a beginner with animations and have been experimenting with
I have recently been experimenting with python generators a bit, and I came across
I've been experimenting with Drupal 7 quite a bit and have a doubt with
I have been experimenting with WP7 apps today and have hit a bit of
I have a Windows Server 2003 64-Bit VPS, and I'm experiencing a problem with
I've been searching quite a bit (and experimenting with monkey patching) for a solution
been experimenting with unordered list UL and i have seem varios examples of using
I'm having a bit of trouble trying to get structs to work properly when

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.