元素定位没问题。
jquery代码:
$("#dataList .text-center").click(function () {
var id = $("#dataList input[type='hidden']").val();
alert(id);
if (confirm("确定删除吗?")) {
window.location = "${pageContext.request.contextPath}/role/del?id=" + id;
}
});
jsp代码:
<table id="dataList"
class="table table-bordered table-striped table-hover dataTable">
<thead>
<tr>
<th class="" style="padding-right: 0px"><input
id="selall" type="checkbox" class="icheckbox_square-blue">
</th>
<th class="sorting_asc">ID</th>
<th class="sorting_desc">角色名称</th>
<th class="sorting">角色描述</th>
<th class="sorting">操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="role" items="${roleList}" varStatus="varstatus">
<tr>
<td><input type="checkbox" ></td>
<td><input type="hidden" value="${role.id}" > </td>
<td>${varstatus.count}</td>
<td>${role.roleName}</td>
<td>${role.roleDesc}</td>
<td class="text-center">
<a href="#" class="btn bg-olive btn-xs" >删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
选择删除后,传的参数Id一直是1.。。。。。。选任何一个删除,id都是1