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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:22:59+00:00 2026-05-25T23:22:59+00:00

I have a few fields that a user can fill in (e.g., name, number,

  • 0

I have a few fields that a user can fill in (e.g., name, number, address), then they can click “Add” which creates a div that displays the information they just entered with a “Remove” button (a href) for each entry. The problem I’m having is that once the DOM is ready, the remove buttons do not work. I’ve hardcoded a remove button that removes the 3rd div (3rd is arbitrary), and that works, but not the ones that are generated after the page is loaded. My question is how can I have the remove buttons work after the DOM is ready?

Here is the remove function (id is passed in, so it knows which div to remove):

function remove(id) {
    $("div.reviewSub"+id).remove();
}

And here is the handler to call the function:

$(".remove").click(function(event) {remove(event.target.id);});

The way I display the data after it has been retrieved is with .append():

$(".reviewSub"+num).append("<a href=\"#\" class=\"remove\" id=\"" + num + "\">Remove</a>");
  • 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-25T23:23:00+00:00Added an answer on May 25, 2026 at 11:23 pm

    You can use the live method in jQuery.

    $('.remove').live('click', function(event){
        remove(event.target.id); 
    });
    

    I suspect that you have the code $(".remove").click(function(event) {remove(event.target.id);}); before you are appending the DOM. As a result, jQuery has not been able to bind the click event to the element as the element doesnt exist yet.

    More documentation here http://api.jquery.com/live/

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

Sidebar

Related Questions

I have a few tables that have similar fields but not exactly the same.
I have a form with a few input fields. When a user clicks on
I have a page with a few fields and a runtime-generated image on it.
I have a webform with quite a few fields (between 15 to 40, based
I have problem with TinyMCE editor. I have form with few text fields and
I have few different applications among which I'd like to share a C# enum.
I have a form which one of it's fields is a code and description,
Imagine I have a class that represents a simple washing machine. It can perform
I have a nice clean UI within a table view which has a few
We currently have some php code that allows an end user to update records

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.