<tr class="item-row" id="itemsRow">
<td></td>
<td><input class="tInput" id="invoiceNo" readonly/> </td>
<td><input class="tInput" id="clientId" readonly /> </td>
<td><input class="tInput" id="issueDate" readonly/></td>
<td><inpu class="tInput" id="netTotal" readonly /> </td>
<td><input class="tInput" id="amountDue" readonly /> </td>
<td><input class="tInput" id="status" readonly /> </td>
</tr>
我試着當我點擊「輸入ID =地位」得到的「輸入ID = invoiceNo的價值得到的值使用下面的代碼如何通過單擊另一個<input>在同一<tr>不同
var invno = $(this).closest('tr td:nth-child(2) input').val();
alert(invno);
It alerts'undefined'
那麼如何解決這個問題?
使用DOM遍歷來查找具有ID(該頁面應該是唯一的)的元素較慢,寫入較複雜,並且對讀取該代碼的其他人來說稍微不明顯。只需使用ID選擇器。 – 2012-03-21 08:47:02
犯錯,我是唯一一個看到問題有多個ID相同 - 每個表中有一行? – frumbert 2012-03-21 09:10:05