首页 新闻 会员 周边

怎么通过jQuery删除table的一行呀

0
[已解决问题] 解决于 2017-02-22 13:02

@model IQueryable<crudText.Models.NewsInfo>
@using crudText.Models
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$(".delete").click(function () {
var nid = $(this).attr("nid");
alert(nid);
$.post("@Url.Action("Delete","NewsInfo")", { "id": nid }, function (data) {
if (data == "OK") {
$(this).parent().parent().remove();  //这里使用进行删除无反应
}
})

});
})
</script>
<title>Index</title>
</head>
<body>
<div>
<table border="1">
<thead>
<tr>
<th>编号</th>
<th>标题</th>
<th>分类</th>
<th>编辑</th>
<th>删除</th>
</tr>
</thead>
<tbody id="tbody">
@foreach(NewsInfo item in Model)
{
<tr>
<td>@Html.ActionLink(item.nid.ToString(),"Detial","NewsInfo",new RouteValueDictionary(new { id=item.nid}),null)</td>
<td>@item.nTitle</td>
<td>@item.NewsType.tTile</td>
<td>@Html.ActionLink("编辑","Edit","NewsInfo",new RouteValueDictionary(new {id=item.nid }),null
)</td>
<td><a href="javascript: void(0)" nid="@item.nid" class="delete">删除</a></td>
</tr>
}
</tbody>
</table>
</div>
</body>
</html>

米其林5212的主页 米其林5212 | 菜鸟二级 | 园豆:212
提问于:2017-02-22 12:30
< >
分享
最佳答案
0

提前获取父级对象,晕了....

米其林5212 | 菜鸟二级 |园豆:212 | 2017-02-22 13:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册