jQuery的AJAX添加表TR于表结尾 [英] jQuery AJAX adding table tr at end of table
本文介绍了jQuery的AJAX添加表TR于表结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有jQuery的code,增加了最后一个响应< TR>
像这样的表:
I have jQuery code that adds a response to the last <tr>
of a table like so:
var table = '<td>' + result.table.product + '</td><td>' + result.table.code + '</td><td>' + result.table.value + '</td><td>' + result.table.time + '</td>';
$('#poo tr:last').after(table);
这里是我的表:
And here is my table:
<?php
$sql="SELECT * FROM wp_scloyalty WHERE userid = '$user_id' ORDER BY date ASC";
$result=mysql_query($sql);
?>
<table id="poo" style="margin:10px 0px 0px 0px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><strong>Product</strong></td>
<td><strong>Code</strong></td>
<td><strong>Value</strong></td>
<td><strong>Date Redeemed</strong></td>
</tr>
<?php while($rows=mysql_fetch_array($result)){ ?>
<tr class="currentpoints">
<td><? echo $rows['product']; ?></td>
<td><? echo $rows['code']; ?></td>
<td><? echo $rows['value']; ?></td>
<td><? echo $rows['date']; ?></td>
</tr>
<? } ?>
<tr class="currentpoints">
<td id="producttd"></td>
<td id="codetd"></td>
<td id="valuetd"></td>
<td id="datetd"></td>
</tr>
</table>
我的问题是,当我添加多个条目它试图以适应他们都进入最后的潮流。有没有一种方法来添加一个TR或某事的最后一个潮流已被填充后?
My problem is that when I add more than one entry it tries to fit them all into the last tr. Is there a way to add a tr or something after the last tr has been populated?
谢谢!
推荐答案
有一种方法可以插入一个全新的行,但你要记住隐式插入&LT; TBODY
元素,所以你要插入新行作为该元素的孩子。
There is a way to insert a whole new row, but you have to remember the implicitly inserted <tbody
element, so you have to insert the new row as a child of this element.
var table = '<tr><td>' + result.table.product + '</td><td>' + result.table.code + '</td><td>' + result.table.value + '</td><td>' + result.table.time + '</td></tr>';
$('#poo > tbody').append( table );
这篇关于jQuery的AJAX添加表TR于表结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文