<table class="table table-bordered">
<thead>
<th>id</th>
<th>username</th>
<th>realname</th>
<th>password</th>
<th>registerTime</th>
<th>telephone</th>
<th>statu</th>
<th></th>
</thead>
<tbody id="tab">
<tr th:each="l : ${list}">
<td th:text="${l.id}" id="delId">id</td>
<td th:text="${l.username}">username</td>
<td th:text="${l.realname}">realname</td>
<td th:text="${l.password}">password</td>
<td th:text="${l.registerTime}">registerTime</td>
<td th:text="${l.telephone}">telephone</td>
<td th:text="${l.statu}">statu</td>
<td width="70px">
<a href="#" onclick="del(this)"><span style="margin-right: 20px" class="glyphicon glyphicon-trash" ></span></a>
<a href="#" onclick="edit()"><span class="glyphicon glyphicon-edit"></span></a>
</td>
</tr>
</tbody>
</table>
<script>
function del(obj){
var col = $(obj).parent().parent().find("td:eq(0)").text();
alert(col);
}
</script>
obj是a标签层的,parent()返回a标签的上一层td标签,parent()返回再上一层tr层,find(“td:eq(0)”)是选择tr中的第一个td,text()获取td标签里的内容,即当前行的第一列的数据