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 {
}
});
jQuery ajax使用$(this).parent()无效解决方法
转载Hello_Martin 博主文章分类:jquery
文章标签 ajax jquery ajax 父级元素 文章分类 Python 后端开发
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
popupwindow showAsDropDown 无效解决方法
今天运行一个很久之前做的项目的时候,发现界面变成了这个样子,就是一个普通的popw
popwindow showAsDropDown pop showAs popwindow Show android -
jquery ajax return值 没有返回 的解决方法
//添加async:false.即修改为同步//等ajax给bol赋值完毕后,才执行下面的js部分。而异步的话,还没有来得及赋值,就已经return了。
jQuery 曾祥展 ajax return值 没有返回 赋值