Deleting row in table with Jquery in mvc project

前端 未结 4 1325
感情败类
感情败类 2021-01-06 15:55

I generate the following html code


        @for (int i = 0; i < Model.listUsers.Count; i++)
        {
            
4条回答
  •  萌比男神i
    2021-01-06 16:18

    You are generating duplicate id attributes for your button which is invalid html and the script will only be called once because you then delete the button. Instead remove the id and use a class name instead

    
    

    and modify the script to

    $(".delete").on("click", function () {
      var tr = $(this).closest('tr');
      tr.remove();
    });
    

提交回复
热议问题