我有一张桌子,在这张桌子上我有id="edit"
. 现在,我想要的是在单击任何单元格时获取相应列的标题名称。到目前为止,根据之前提出的问题,我所拥有的是:
$('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>