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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:11:20+00:00 2026-06-18T08:11:20+00:00

I have this <li> , that when you click it, it creates another <li>

  • 0

I have this <li>, that when you click it, it creates another <li> before it (with a bunch of classes applied to it), which is all working great.. Problem is, I can’t modify (via jQuery) the newly created <li> elements because they were created dynamically.

Currently, it is setup as:

 $(".foo").on("click", function() {
//Blah blah blah
});

And I have already tried the code below instead, which still did not work.

$(".foo").on("click", function() {
//Blah blah blah
});

Thanks for your help in advance!

  • 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-18T08:11:21+00:00Added an answer on June 18, 2026 at 8:11 am

    Try this approach:

      $("ul").on('mouseup', '.item', function() {
        $(this).toggleClass("completed");
      });
    

    JS Fiddle demo.

    The problem you were having is that the .item elements weren’t present in the DOM at the point at which the mouseup event was bound to them. This approach binds the mouseup to the ul which does exist, and uses the on() method to listen for that event and, if the target element matches the selector (.item) passed to the method it implements the anonymous function (the third argument passed to the method).

    If the target does not match that selector then the event either does nothing or contiunues to propagate through the ancestors.

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

Sidebar

Related Questions

I have this working query that outputs URL and click counts from database. <?php
I have an ASP.NET form (C#) but which I click this button that should
I have this method that changes an larger image source on click. I need
I have this website http://wedessertmore.com that has some forms popup when you click on
I have 4 buttons that when click starts a new activity class. This works
I have a menu click event that looks something like this.... Public Sub ToolbarManager_ToolClick(sender
I have a program that simulates mouse click. Code is something like this: [DllImport(user32.dll,
I have fragment that on a component click pop-ups DialogFragment. This dialog fragment holds
I have a contextmenu that shows on certain elements when you right click. This
okay? I have a button that is inside an updatepanel, click on this button

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.