Deleting row in table with Jquery in mvc project

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

I generate the following html code


        @for (int i = 0; i < Model.listUsers.Count; i++)
        {
            
4条回答
  •  迷失自我
    2021-01-06 16:40

    IDs in HTML must be unique, use a class instead then you can use Class Selector (".class").

    Selects all elements with the given class.

    HTML

    
    

    Script

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

提交回复
热议问题