jquery 动态删除tr行数据
jquery代码:
$(".del").click(function() { var stuid = $(this).parent().parent().attr("id"); $.post(ctx + "/del?stuid=" + stuid,function(data) { if(data.result == "ok"){ $("#" + stuid).fadeOut("slow", function (){ $(this).remove(); }); } else if(data.result == "error"){ alert("删除出错!"); } }); });
jsp代码:
<table class="altrowstable" id="alternatecolor"> <tr> <th>编号</th> <th>姓名</th> <th>年龄</th> <th>地址</th> <th>管理员</th> <th>操作</th> </tr> <c:forEach items="${stuList}" var="stu" varStatus="st"> <tr id="${stu.id }"> <td>${st.index+1 }</td> <td><a href="" class="update" title="修改">${stu.name }</a></td> <td>${stu.age }</td> <td>${stu.address }</td> <td> <c:if test="${stu.isadmin == "0" }"> 否 </c:if> <c:if test="${stu.isadmin == "1" }"> 是 </c:if> </td> <td><a href="#" class="del">删除</a></td> </tr> </c:forEach> </table>
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇: html table中嵌入checkbox实现全选