我有一张桌子,想在我用鼠标单击的行下方添加一个加载的 ajax。但是我不知道如何获取索引,而是将其附加到末尾。
例如,单击“hol”,该行应插入“hol”行下方。
<table id="tab_open_deals" class="table table-condensed table-striped cb_table-hover">
<thead>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
</thead>
<tbody id="search_result">
<tr>
<td>Lunch Deal- Light</td>
<td>39.90</td>
<td>29 Dec 2012</td>
</tr>
<tr>
<td>hol</td>
<td>1499.00</td>
<td>8 Jan 2013</td>
</tr>
</tbody>
</table>
$(document).ready(function() {
$('#tab_open_deals tbody tr').off('click').on('click', function() {
var row = $('<tr/>');
$(row).load('/echo/html/', {
html: '<td class="override" colspan="4"><table class="table-striped sub_table-hover"><thead><tr><th>Sub1</th><th>Sub2</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></tbody></table></td>'
});
$(this).parent().append(row);
});
});