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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:35:42+00:00 2026-06-06T20:35:42+00:00

I have a delete button on a table and a jquery on click eventlistener

  • 0

I have a delete button on a table and a jquery on click eventlistener for the button.
here is the code

$(".delbtn").click(function () { 
    var count = 0;
    var $row = jQuery(this).closest('tr'); 
    var $columns = $row.find('td'); 

    var values = ""; 

    jQuery.each($columns, function(i, item) { 
        if( count == 0 ){delFund = item.innerHTML}
        if( count == 1) {delOrg  = item.innerHTML}
        if( count == 2) {stat = item.innerHTML }    
        count++
    }); 

//the below lines of codes would display how to show values on a browser like 
// firefox or chrome.
//console.log(delFund, delOrg);


    $(this).closest("tr").fadeTo(500, 0, function () {  
        $(this).remove(); 
    }); 


//update the item on the database table for deletion.
  $.ajax({type: "POST",
          url: "dbfunctions.jsp",  
          data: {TYPE:'D', fundval: delFund, orgval: delOrg, tuidval:tuid, status:stat }}).done(function( msg )
          {  
            //alert(msg);
          });

});

This all works fine,my problem is that i query a database which i then used to update the html table with this data and I add an new button to the last row on the table. However the button does not respond when i click it. I believe is because there has not been an event listener attached to it. So my my question is how can I update the button so that the event listener that i have already added to all the previous buttons also gets attached to the new dynamically generated button?

here is the code snippet of how i add the item to the end of my table.

$("#thisTable > tbody").append( 
                                        "<tr><td>"+thisfund.value+"</td>"+
                                        "<td>"+thisorg.value+"</td>"+
                                        "<td>"+'PENDING ACCESS'+"</td>" +
                                        "<td>"+"<a class='delbtn' href='#'>X</a>"+"</td></tr>");
        thisfund.value = "";// set the input boxes back to null
            thisorg.value  = "";

          });
  • 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-06T20:35:43+00:00Added an answer on June 6, 2026 at 8:35 pm

    Try this man:

    API: http://api.jquery.com/on/

    The .on() method attaches event handlers to the currently selected set of elements in the jQuery object.

    Any event names can be used for the events argument. jQuery will pass through the browser’s standard JavaScript event types, calling the handler function when the browser generates events due to user actions such as click.

    In your case even though the new tr with class='delbtn' the .on event will take it over.

    Hope this helps,

    code

    $(document).on('click','.delbtn',function () { 
        var count = 0;
        var $row = jQuery(this).closest('tr'); 
        var $columns = $row.find('td'); 
    
        var values = ""; 
    
        jQuery.each($columns, function(i, item) { 
            if( count == 0 ){delFund = item.innerHTML}
            if( count == 1) {delOrg  = item.innerHTML}
            if( count == 2) {stat = item.innerHTML }    
            count++
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table AVUKAT Columns--> HESAP, MUSTERI, AVUKAT This is my delete button
Possible Duplicate: how to delete row from datagridview with a delete button? I have
i am creating the textboxes dynamically using jquery on a button click. <table width=100%
I have this simple html piece of code, whenever I click on any of
Here's my goal: have a table of data with edit/delete buttons. The edit buttons
I have an HTML table with various rows, each has a delete button with
I'm using the following jquery code to show a contextual delete button only for
Basically is to click button to generate table row, then click minus button to
I have one HTML Table... This HTML table's first row is a static, when
I have a table with rows in it. When I click a button it

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.