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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:14:33+00:00 2026-05-18T05:14:33+00:00

I have a little project I am working on and I am using jQuery.

  • 0

I have a little project I am working on and I am using jQuery. I tried using a little jQuery to change the class to change some css styles when clicked but it does not seem to work.

heres the important html:

<ul id="UInavList">
        <li class="selectedNav"><a href="javascript:;">My Activity</a></li>
        <li ><a href="javascript:;">My Tests</a></li>
        <li ><a href="javascript:;">Messaging</a></li>
        <li ><a href="javascript:;">Search</a></li>
    </ul>

and heres the javascript:

$('#UInavList li').click( function() {
    $('#UInavList li').removeClass('selectedNav');
    $(this).addClass('selectedNav');
})

If you want to see all the code go here: http://jsfiddle.net/chromedude/XXXwL/

  • 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-18T05:14:34+00:00Added an answer on May 18, 2026 at 5:14 am

    Your code already works in jsfiddle, you just hadn’t set the framework to include jQuery on the right hand side – also with no class set to see the changes, it was hard to tell if it worked.

    Look at this demo, it is identical to yours except it has a CSS entry to show up the change and I set the jQuery option on the side.

    http://jsfiddle.net/XXXwL/8/

    I would however target the anchor rather than the li itself and use $(this).closest('li').addClass('selectedNav'); as the second line for preference, remembering to return false if you target an anchor with click() so that the href is not followed.

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

Sidebar

Related Questions

I'm working on project with listview,but I have a little problem. I'm using SimpleAdapter
I'm working on a Rails project OldApp that's using STI for some class Foo.
I am working on little project to learn jQuery, and I have a twitter
I'm working on a little project, basically I have some text on my PHP/HTML
I am currently working on my own little project, but I have a little
So working on an little project but thinking about making maps efficient. I have
I've started working on a little ruby project that will have sample implementations of
So I have a little bit of a problem. I working on a project
Hy guys! I am currently working on a little WPF project using MVVM via
I have a question, I'm currently working on a little project of mine and

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.