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

  • Home
  • SEARCH
  • 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 7176289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:28:36+00:00 2026-05-28T16:28:36+00:00

I want to edit data in a table using jQuery. The HTML markup is:

  • 0

I want to edit data in a table using jQuery.
The HTML markup is:

<tr id="unique_rid1">
    <td>15/01/2012</td>
    <td>4</td>
    <td><a href="#" class="edit_work_done" id="unique_rid1">Edit</a></td>
</tr>

When user clicks on “Edit”, this link becomes “Update” and the table cell contaning the number 4 turns into a text field.
Here is the jQuery code for that:

//change the work done to be a form when "edit" is clicked
var toUpdate;
$(".edit_work_done").click(function(){
    $(this).removeClass('edit_work_done').addClass('update_work_done').html("Update!");
    toUpdate = $(this).parent().parent().children('td').eq(1);
    var Hours = toUpdate.html();
    toUpdate.html('<input type="number" value="'+ Hours +'" class="new_hour span1"/>');
});
//change the work done to be static value when "Update!" is clicked
$(".update_work_done").live("click", function(){
    $(this).removeClass('update_work_done').addClass('edit_work_done').html("Edit");
    var newHours = $(this).parent().parent().find("input.new_hour").val();
    toUpdate = $(this).parent().parent().children('td').eq(1);
    toUpdate.html(newHours);
});

However, “live” catches the class change immediately and does not allow the <input> tag to come up or the link to change to Update!

Question: How should I bind this event? (as a simple “click” event does not capture the dynamically updated class change)

  • 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-28T16:28:36+00:00Added an answer on May 28, 2026 at 4:28 pm

    You should give live to both

    var toUpdate;
    $(".edit_work_done").live("click", function(){
        $(this).removeClass('edit_work_done').addClass('update_work_done').html("Update!");
        toUpdate = $(this).parent().parent().children('td').eq(1);
        var Hours = toUpdate.html();
        toUpdate.html('<input type="number" value="'+ Hours +'" class="new_hour span1"/>');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input edit field where the user can enter data. I want
I have this html code that i want to edit with jQuery. Here is
I want to allow the user to edit by data by row, so only
When using an ASP.NET WebForms ListView control to display data in an HTML table
I'm using binary uuids for keys. Is there any way to edit table data
I want to display and edit some objects in a WPF data grid and
I have a text file that I want to edit using Java. It has
I am a Cake PHP novice. I want to edit the table Issue. This
I am using the datatables jquery plugin and want to sorty by dates. I
Using the Authors/Books catalog example, let's say I want to edit the info for

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.