现在的位置: 首页 > 综合 > 正文

jquery 动态删除tr行数据

2013年03月20日 ⁄ 综合 ⁄ 共 732字 ⁄ 字号 评论关闭

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>

抱歉!评论已关闭.