請問var thisid = $(this).parent().siblings("th:eq(0)").text();為什么要加"th:eq(0)"?
this指被選中的td標簽,則$(this).parent().siblings()表示獲取tr的所有兄弟標簽,那為什么括號中還要"th:eq(0)",如果要加,不應該是"tr:eq(0)"嗎
<script>
。。。
var thisid = $(this).parent().siblings("th:eq(0)").text();
。。。
</script>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="500">
<thead>
<tr>
<th scope="col">id列</th>
<th scope="col">name列</th>
<th scope="col">age列</th>
</tr>
</thead>
<tbody>
<tr>
<td class="content">1</td>
<td class="text">張三</td>
<td class="position">18</td>
</tr>
<tr>
<td class="content">2</td>
<td class="text">李四</td>
<td class="position">19</td>
</tr>
<tr>
<td class="content">3</td>
<td class="text">王五</td>
<td class="position">20</td>
</tr>
</tbody>
</table>
</body>
uj5u.com熱心網友回復:
你確定this是td元素嗎?,td元素的parent() 是 tr元素,tr元素的兄弟只可能是tr元素,不可能是th或tduj5u.com熱心網友回復:
已解決。this是td標簽中的input標簽轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/85644.html
標籤:JavaScript
上一篇:小程式背景圖與設定的input控制元件,不同解析度錯位
下一篇:問個ssl的問題~
