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

  • Home
  • SEARCH
  • 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 766011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:58:39+00:00 2026-05-14T16:58:39+00:00

I have a ol list: <ol> <li class=group1>item 1</li> <li class=group1>item 2</li> <li class=group2>

  • 0

I have a ol list:

<ol>
<li class="group1">item 1</li>
<li class="group1">item 2</li>
<li class="group2"> item 3</li>
<li class="group3">item 4</li>
<li class="group1">item 5</li>
<li class="group3"> item 6</li>
<ol>

and a set of checkboxes which correspond to the class names

<input type="checkbox" value="group1" />group 1
<input type="checkbox" value="group2" />group 2
<input type="checkbox" value="group3" />group 3

What I want to happen is that when a user clicks on a checkbox to ‘tick’ it, any li rows which are not checked are fadedOut (change opacity) and then any rows which have the class which matches the value of the checkbox are highlighter (background colour changed to yellow).

So for example if group 3 was clicked, item 4 and item 6 would be highlighted. Then if group 2 was clicked item 3 would be highlighted (item 4 and 6 would remain highlighted). If group 2 was un-ticked, item 3 would become faded out although item 4 and 6 would remain highlighted.

The code I have at the moment is:

$('input').click(function(){
    input = $(this);
    classVal = "." + input.val();
    elements = $(classVal );

    if (input.is(':checked')) {
        elements.css("background-color", "#FFFF00");
    } else {
        elements.css("background-color", "");
    }
});

This handles the highlighting but does not do the fading of the unchecked elements. I know I can change the opacity using css(“opacity”, 0.33) or fadeTo(“slow”, 0.33) but not sure how to handle this in the code and where to put it.

If any of my other code can be tidied up also please let me know

Thanks

  • 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-14T16:58:39+00:00Added an answer on May 14, 2026 at 4:58 pm

    The jQuery code:

    $('input:checkbox').bind('click', function(){
        var checkedClasses = $("input:checked").map(function() {
            return $(this).val();
        });
        var uncheckedOpacity = (checkedClasses.length == 0) ? 1.0 : 0.5;
        $('ol li').css({opacity: uncheckedOpacity, backgroundColor: 'transparent'});
        $.each(checkedClasses, function(index, value){
            $('.' + value).css({backgroundColor: '#ff0', opacity: 1.0});
        });
    });
    

    This HTML:

    <ol>
        <li class="group1">item 1</li>
        <li class="group1">item 2</li>
        <li class="group2">item 3</li>
        <li class="group3">item 4</li>
        <li class="group1">item 5</li>
        <li class="group3">item 6</li>
    <ol>
    
    <form>
        <label><input type="checkbox" value="group1" />group 1</label>
        <label><input type="checkbox" value="group2" />group 2</label>
        <label><input type="checkbox" value="group3" />group 3</label>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a list in a class which will be used in
I have a list of items as such: public class Item { public int
I have a List of the following object : public class Item { public
I have this class public class Item { public Coordinate coordinate { get; set;
i neeed something like this in C#.. have list in class but decide what
I have List of particular class. I want to save this List at a
I have a list of class object that I created as a variable in
I have a list of class items List<MyClass> I have a seperate object that
I have a list of ProjectItem class instances: List<ProjectItem> allProjects . I need to
I have a list of this class: public class Data { public string name

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.