我有一個表像下面如何使用JQuery獲取記錄表並使用AJAX將其發送到服務器?
<table cellspacing="0" rules="all" border="1" id="ContentPlaceHolder1_GridView1" style="border-collapse:collapse;" class="table table-striped">
<tbody>
<tr>
<th scope="col"> </th>
<th scope="col">Bill NO</th>
<th scope="col">Date</th>
<th scope="col">Description</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
</tr>
<tr>
<td><input id="Checkbox0" class="checkBoxClass" type="checkbox">/td>
<td>111</td>
<td>12-22-2014</td>
<td>computer problem</td>
<td>Invoice</td>
<td class="ActualAmount">7689.00</td>
</tr>
<tr>
<td><input id="Checkbox1" class="checkBoxClass" type="checkbox">/td>
<td>112</td>
<td>12-22-2014</td>
<td>Printer problem</td>
<td>Invoice</td>
<td class="ActualAmount">7689.00</td>
</tr>
</tbody>
</table>
我想獲得的BillNo
和ActualAmount
的值,如果在該行
首先選中複選框,我嘗試使用,以獲取該行的值這下面的代碼
alert('value = ' + $("#ContentPlaceHolder1_GridView1 .checkBoxClass input[type='checkbox']:checked").closest("td").val())
它提醒value = undefined
我試圖得到這樣Jfiddle
那個小提琴與你的代碼有什麼關係?注意:''最接近(「td」)'輸入是封閉輸入的'td'。你可能想要它是下一個兄弟而不是 –
@Jaromandax不,我只是試過它是否顯示下一個值。但我只想得到第2和第6個td值。每行有10個td,爲了清楚起見,我在這裏刪除了一些td元素 –
,但是最接近輸入的是td將輸入括起來,這樣你發佈的代碼是完全不足的 –