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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:07:59+00:00 2026-05-16T03:07:59+00:00

I have a list that has 5 items in, the first one (on load)

  • 0

I have a list that has 5 items in, the first one (on load) is active (with a class of ‘active’ added by jQuery). They all have background images associated with them. If I click any of the li’s another div updates with relevant content (this is working).

However I’m struggling with the following:

If you click an li, update its background image to be colour (suffix of ‘-cl.png’). When I hover over another one, update its background image to be colour and keep the clicked one (with a class of ‘active’) colour too. If an li is not hovered over set the background image to be black and white (suffix of ‘-bw.png’) but keep the active one colour.

Hope I’ve explained myself clearly. Any ideas on how I can achieve this? Thanks, Brett

Here’s my HTML:

<ul class="graduate_tab">
<li class="graduate1"><a href="#grad1"><span class="gradimg1">grad1</span></a></li>
<li class="graduate2"><a href="#grad2"><span class="gradimg2">grad2</span></a></li>
<li class="graduate3"><a href="#grad3"><span class="gradimg3">grad3</span></a></li>
<li class="graduate4"><a href="#grad4"><span class="gradimg4">grad4</span></a></li>
<li class="graduate5"><a href="#grad5"><span class="gradimg5">grad5</span></a></li></ul>
  • 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-16T03:08:00+00:00Added an answer on May 16, 2026 at 3:08 am

    First, I would do most of the work in CSS, like this:

    .graduate1 { background: url(image1-bw.png); }
    .graduate1.active, .graduate1:hover { background: url(image1-cl.png); }
    .graduate2 { background: url(image2-bw.png); }
    .graduate2.active, .graduate2:hover { background: url(image2-cl.png); }
    //etc...
    

    Then in jQuery all you need to worry about is the active class, like this:

    $('.graduate_tab li').click( function() {
      $(this).addClass('active').siblings().removeClass('active');
    });
    

    Using .addClass() on the clicked one and .removeClass() on the rest will move the active class to the clicked one…if you want to be able to remove it from an already active one (toggle it off) you can replace .addClass() with .toggleClass() for that behavior.

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

Sidebar

Related Questions

I have a class that basically has two methods the first one takes a
I have a list that has two items: projects and groups. Projects can go
I have a string list (TStrings) that has a couple thousand items in it.
I have a list view that displays a collection of items, each item has
I have an app that has a list of items. My customer prefers to
I have a ListBox in Silverlight that has a list of items inside. Each
I have a list of items of a custom class. That class contains an
I have a list of data that is a schedule. Each item has a
I have a list that has some chapter numbers in string. When I sort
I have a drop down list that has options that need to be passed

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.