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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:18:47+00:00 2026-05-25T02:18:47+00:00

I have few <li> ‘s with a checkbox on each <li> which the value

  • 0

I have few <li>‘s with a checkbox on each <li> which the value of it is saved into a database. On document load, the <li>‘s that have the checkbox selected, I want to add a class ‘.done’.

I tried this:

if (currentTODO.find('.status').is(":checked")) {
            currentTODO.find('.text').addClass("done");
            alert('Test.');
    }

but it works only if it used under click function, mousemove etc but not on document load. Also, If I have that piece of code under on Document load, nothing else works.

I hope someone can help me out.

Thanks alot

  • 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-25T02:18:47+00:00Added an answer on May 25, 2026 at 2:18 am

    Something like this:

    $('input[type="checkbox"][checked="checked"]').parent().addClass('done');
    

    http://jsfiddle.net/SBMEm/

    Edit: This might be closer to what you were trying to do:

    $('li').filter(function() {
        return $(this).find('input').is(':checked');
    }).addClass('done');
    

    http://jsfiddle.net/SBMEm/7/

    I have no problem with any of these working on document load.

    Edit: Incidentally, as is often the case with a jQuery-based solution, you can just do this in CSS:

    input:checked:after {
        margin-left: 20px;
        content: "Done";
        display: block;
    }
    

    http://jsfiddle.net/3SRQd/

    Unless you’re interested in doing something else with it programmatically or need it to actually have the class for some other reason.

    Extra edit: How about this? http://jsfiddle.net/EDs3N/12/ (Incidentally, I’m headed home.)

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

Sidebar

Related Questions

I have few repositories and each have config.php file that contain information about database
I have few 'so' files that I need to load in maven java project
I have few values that are DB driven/or coming from other system which i
I have few html pages from my old site that I want to place
I have few links displayed in JEditorPane ex: http://www.google.com/finance?q=NYSE:C http://www.google.com/finance?q=NASDAQ:MSFT I want that I
I have few images, which come dynamically from database. When a user hovers over
I have few EditText objects with text inside. I want that on the first
I have few graphic effects on image which i am able to run on
I have few table view controllers and I want selections from them to be
I have few questions as below: 1) I have a Java program which tryning

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.