[英]How to append a table row towards last of a row with a specific class?
我試圖將一行附加到asp數據網格的html格式。 我的網格正在分頁,並且也將其轉換為html格式的行。 因此,我在具有實際記錄的行中添加了一個類。 現在,我需要將html表行添加到網格。 這應該附加到記錄的末尾。 有人知道該怎么做嗎?
表結構:
<table>
<th>
</th>
<tbody>
<tr class="clientData">1</tr>
<tr class="clientData">2</tr>
<tr class="clientData">3</tr>
<tr>Exclude This Row</tr>
<tr>Exclude This Row</tr>
</tbody>
</table>
腳本:
{ $("#ctl00_Content_GrdCustomer tbody").append(selCustomersRow); } //
就像是
$('#ctl00_Content_GrdCustomer tbody tr.clientData').last().after(selCustomersRow);
或像Angel的評論一樣,直接選擇最后一個tr.clientData:
$('#ctl00_Content_GrdCustomer tbody tr.clientData:last').after(selCustomersRow);
更好的方法是使用正確的表標簽。
即
<table>
<thead>
<tr>
<td>Column header 1</td>
<td>Column header 2</td>
<td>Column header 3</td>
</tr>
</thead>
<tbody>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Column footer 1</td>
<td>Column footer 2</td>
<td>Column footer 3</td>
</tr>
</tfoot>
</table>
您可能不需要標題,但您可以將所有“記錄”粘貼在肢體內,將分頁粘貼在足部。
這樣你可以使用
$("#ctl00_Content_GrdCustomer tbody").append(selCustomersRow);
它將在行的末尾附加行,但在分頁內的分頁之前。
嘗試...
{ $("#ctl00_Content_GrdCustomer tbody tr").last().append(selCustomersRow); }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.