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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:32:44+00:00 2026-06-15T14:32:44+00:00

http://jsfiddle.net/2Wpfw/3/ I’m not sure if my question title is the best description. I’m after

  • 0

http://jsfiddle.net/2Wpfw/3/

I’m not sure if my question title is the best description.

I’m after some jquery help please with some way of checking if a input=”checkbox” is checked or not, and then to add a class or remove depending on the checkbox state.

Anyway my form markup looks like this…

<form>

    <ul class="select-wrapper">

        <li class="select-area">

            <input type="checkbox" name="colour1" id="colour1" value="black">

            <label for="colour1">Number 1</label>

        </li>

    </ul>

</form> 

See this fiddle with my extremly poor attempt. http://jsfiddle.net/2Wpfw/3/

As you can see when you hover over the <li> they go red, but dont stay red if a input is already checked or if the input is selected live.

I would like them to stay red when the input is selected live on the page, and also go back to black if it is unchecked. The form is ajax based so if there is an error, I would like the input li’s that are checked to appear in red (I will be doing this by running the function again after form is submitted).

I am making these appear in red my adding and removing the .box-checked class.

Can any one see a possible work arround as I’m quite lost as in where to start.

Any help would be hugely appreciated. Thanks

http://jsfiddle.net/2Wpfw/3/

  • 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-15T14:32:46+00:00Added an answer on June 15, 2026 at 2:32 pm
    $(".select-area input[type='checkbox']").on('change', function() {
        $(this).closest('.select-area').toggleClass('box-checked', this.checked);
    });
    ​
    

    FIDDLE

    You also need to be more specific in your CSS, as right now the .box-checked styles are not overriding the original styles, something like :

    .select-area.box-checked {
        background: red;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/2Wpfw/16/ This seems really trivial question but I cannot for the life work this
http://jsfiddle.net/motocomdigital/gUWdJ/ I'm after a jquery scroll technique please that I would like to adapt
http://jsfiddle.net/3QeSe/44/ i am getting undefined any help appreciated ...
http://jsfiddle.net/nWqYL/2/embedded/result/ I've been working on fixing some issues with this prototype site. Myself and
http://jsfiddle.net/tgWKZ/ This worked in the older version of jQuery. Only thing that is stopping
http://jsfiddle.net/psycketom/TUyJb/3/ I recently asked a question to calculate the endpoint of a line in
http://jsfiddle.net/ZtpEU/41/ heres a simple animation in jquery. I'm trying to make it so the
http://jsfiddle.net/kent93/AyEpR/ i want to hide() the loader gif , after the audio has loaded.
http://jsfiddle.net/nwT6v/1/ That's my script basically. How come? I want to add text after clicking
http://jsfiddle.net/JamesKyle/y7hBQ/ I'm making a simple jquery counting function that adds the following classes: First

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.