Delete dynamically-generated table row using jQuery

前端 未结 6 2009
情深已故
情深已故 2020-12-31 02:28

the code below add and remove table row with the help of Jquery the add function works fine but the remove only work if I remove the first row

         


        
6条回答
  •  时光说笑
    2020-12-31 03:02

    You need to use event delegation because those buttons don't exist on load:

    http://jsfiddle.net/isherwood/Z7fG7/1/

     $(document).on('click', 'button.removebutton', function () { // <-- changes
         alert("aa");
         $(this).closest('tr').remove();
         return false;
     });
    

提交回复
热议问题