<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>獲取Table的最后一行Demo</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
</head>
<body>
<table id="tbList">
<thead>
<tr>
<th>編號</th>
<th>名稱</th>
<th>明細</th>
</tr>
</thead>
<tbody>
<tr id="realRow">
<td>1083</td>
<td>佛山</td>
<td>
<table>
<tbody>
<tr>
<td>張三</td>
<td>李四</td>
</tr>
<tr id="childrenRow">
<td>黃二</td>
<td>黃三</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var $lastRow = $("#tbList tr:last");
console.log($lastRow);
</script>
</body>
</html>
得到的是childrenRow,如何才能取到realRow?
uj5u.com熱心網友回復:
var $lastRow = $("#tbList").children().children('tr:last')轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/48747.html
標籤:JavaScript
上一篇:這種ID怎么在兩個元素中使用?
下一篇:求助網頁制作
