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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:55:08+00:00 2026-05-22T00:55:08+00:00

i am trying to make a to do list app. When i click a

  • 0

i am trying to make a to do list app. When i click a span with class “check” then i want to apply a style. Then the class of the span will change to “uncheck”. When click the uncheck then the previous style will restore. Here is the html and jquery what i have done so far.

Problem: Problem is when i first click the span it works The “uncheck” class get removed and “check” class get added. Then the second part not works. I suspect the second part don’t working because the “check” class is not in the dom when document.ready() is runs.

Any help will be greatly appreciated! Thanks!

HTML:

         <div class="note-body">
                <ol>
                    <li>M2u category shown. M2u category shown M2u category shown M2u category shown.
                        <span title="Delete" class="delete"></span>
                        <span title="Task Done!" class="done"></span>
                        <span class="handle"></span>
                        <span class="handle"></span>
                    </li>
                    <li>M2u category shown</li>
                    <li>M2u category shown</li>
                </ol>
            </div>

jQuery:

    $('.note-body ol li span.check').click(function(){
            $(this).addClass('uncheck').removeClass('check');

            $(this).parent().css({'text-decoration':'line-through', 'color':'#5b382e'});

    });

   $('.note-body ol li span.uncheck').click(function(){
            $(this).addClass('check').removeClass('uncheck');

            $(this).parent().css({'text-decoration':'none', 'color':'#5b382e'});

});

RESOLVED:

Had to use the live(); because i am adding dom dynamically. Here is the final code (placed the styles in classes):

$('.note-body ol li span.check').live('click', function(){
            $(this).addClass('uncheck').removeClass('check');
            $(this).parent().addClass('task-done').removeClass('task-notdone');
    });

   $('.note-body ol li span.uncheck').live('click', function(){
            $(this).addClass('check').removeClass('uncheck');
            $(this).parent().addClass('task-notdone').removeClass('task-done');
   });
  • 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-22T00:55:10+00:00Added an answer on May 22, 2026 at 12:55 am

    You are correct. Since the ‘uncheck’ class is dynamically added to the DOM, you need to use the jQuery live API. Try this:

       $('.note-body ol li span.uncheck').live('click', function(){
                $(this).addClass('check').removeClass('uncheck');
    
                $(this).parent().css({'text-decoration':'none', 'color':'#5b382e'});
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an app which on a click of a list item
I am trying to make a method that will go through a list of
I'm trying to make an app that uses the list of songs that a
I am trying to make an Android app which will pull uploaded videos from
I'm trying to create a Django app where the user can make a list
I'm trying to make something like a spellchecker, that will list possible words under
I'm trying to make an app which displays a listview, and when you click
I am trying to make a phone call on a list item click. Here
I am trying to make a list box where I have complete control over
I'm trying to make a list containing different objects. List<Object> list = new ArrayList<Object>();

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.