jQuery ajax使用$(this).parent()无效解决方法

div=$(this).parent(); //先获取父级元素



div.remove(); //再删除



$(".delStu").click(function () {
                       td = $(this).parent().parent();
                       if (confirm("您确认删除么")) {
                           $.ajax({
                               url: "/Demo/Student/DelStudent",
                               type: "POST",
                               data: { ID: $(this).attr('data-id') },
                               success: function (data) {
                                   if(data.msg=="删除成功");
                                   {
                                       console.log(data);
                                       td.remove();
                                   }
                               },
                               error: function () {
                                   console.log("error");
                               }
                           })


                       } else {
                           
                       }
                   });

原文地址:https://www.cnblogs.com/MartinLee/p/7622697.html