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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:30:55+00:00 2026-06-12T03:30:55+00:00

I am trying to change a list item when the user clicks the selected

  • 0

I am trying to change a list item when the user clicks the selected class is changed to the clicked item. I have this code:

$(function() {
    $("a.product-page li").click(function(){
        $(this).parent("a").addClass("selected-page");
        $("#options a.selected-page").removeClass("selected-page");
    });
});

However the removeClass works however the addClass does not.

Here is the Site.

HTML:

<ul id="options">
    <a href="#summary" id="summary" class="product-page selected-page"><span></span><li>Summary</li></a>
    <a href="#specs" id="specs" class="product-page"><span></span><li>Specs</li></a>
    <a href="#media" id="media" class="product-page"><span></span><li>Media</li></a>
    <a href="#reviews" id="review" class="product-page"><span></span><li>Reviews</li></a>
</ul>

CSS:

ul#options {
    margin-left:0px;
}

ul#options li{
    list-style:none;
    padding: 10px 20px;
    background: #CCC;
    border-top: 1px #999 solid;
    border-left: 1px #999 solid;
    border-right: 1px #999 solid;
}

ul#options a{
    display:block;
    border:none !important;
}

ul#options a.selected-page span{
    position:absolute;
    width:0px;
    height:0px;
    border-width:10px;
    border-color:transparent #999999 transparent transparent;
    border-style:solid;
    margin-left:270px;
    margin-top:11px;
}

ul#options a:last-child li {
    border-bottom:1px #999 solid;
}
  • 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-12T03:30:56+00:00Added an answer on June 12, 2026 at 3:30 am
    • You should wrap <a> link tag inside li tag like below,

    HTML:

    <ul id="options">
        <li><a href="#summary" id="summary" class="product-page selected-page"><span></span>Summary</a></li>
        <li><a href="#specs" id="specs" class="product-page"><span></span>Specs</a></li>
        <li><a href="#media" id="media" class="product-page"><span></span>Media</a></li>
        <li><a href="#reviews" id="review" class="product-page"><span></span>Reviews</a></li>
    </ul>
    
    • You are removing the class that you just added. You can move the remove class above the addclass or just use not to exclude this when you remove..

    Code:

    $(function() {
        $("a.product-page", $('#options')).click(function(){
            $(this).addClass("selected-page");
            $("#options a.selected-page").not(this).removeClass("selected-page");            
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to execute this function when a select list's (LevelId0) value change but
I'm trying to change the styling of the list item that holds my link
I'm trying to change the will_paginate links from the format of /list?page=1 to /list/page/1
I´m trying to change a spring jsp example to use freemarker. I changed all
I have a list of items that the user can select. I want it
I've build a custom SharePoint list that programatically adjusts permissions per list item. This
I'm trying to make a list containing names. This list should be modifiable (add,
I have a menu with a bunch of list items. What I am trying
UPDATED: I have the following code, where I am trying to use returned JSON
I am trying to implement a functionality where a user can select a list

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.