Delete dynamically-generated table row using jQuery

前端 未结 6 2056
情深已故
情深已故 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:05

    You should use Event Delegation, because of the fact that you are creating dynamic rows.

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

    Live Demo

提交回复
热议问题