我有一個表,並在該表中我有價值id="edit"
。現在,我想要的是當我單擊任何單元格時獲取相應列的標題名稱。到目前爲止,基於前面提出的一個問題是:jQuery獲得點擊單元格的表頭名稱與編號
$('body').on('click', 'td#edit', function() {
var th = $('this').closest('th').eq($('th').val());
alert(th); // returns [object Object]
.........................
}
你能幫我解決這個問題嗎?
HTML:
<table id="myTable" class="myTable">
<tbody>
<tr>
<th>Select</th>
<th>JobNo</th>
<th>Customer</th>
<th>JobDate</th>
<th>Warranty</th>
<th>RepairStatus</th>
<th>POP</th>
<th>DOA</th>
<th>Model</th>
<th>SN</th>
</tr>
<tr>
<td class="check">
<input type="checkbox" value="12345">
</td>
<td class="edit">
<b>12345</b>
</td>
<td class="edit">gdsgasdfasfasdfa</td>
<td class="edit">2011-01-21</td>
<td class="edit">TRUE</td>
<td class="edit">RP</td>
<td class="edit">FALSE</td>
<td class="edit">0</td>
<td class="edit">5152342</td>
<td class="edit">66665464</td>
</tr>
</tbody>
你不應該有'和'ID values' = edit' ID應該是 – 2013-03-19 08:55:23
是否使用相同的唯一ID多次?你寫了你有價值* s *與'id =「edit」'。 ID應該是唯一的 – Vishal 2013-03-19 08:57:20
什麼是HTML標記。 – 2013-03-19 08:57:25