从jQuery更新表行

时间:2014-03-07 09:00:05

标签: jquery-mobile html-table

我正在构建一个Jquery移动应用程序,因为我创建了一个表,我需要从DB更新该表行。

这是我的HTML ...

  <table style="width:100%;" id="cart_table">
     <tr>
       <th>Item</th>
       <th>Qty</th>
       <th>Price</th>
       <th>Delete</th>
     </tr>       </table>

我调用showall()方法,在点击购物车按钮时显示其中的所有购物车商品。

 var row = ('<tr><td align="center"><a>'+cartitem1+'</a></td> <td align="center"><a>'+cart_qty+'</a></td> <td align="center"><a>'+cart_price+'</a></td><td align="center"><a><img src=""/></a></td></tr>');
      $("#cart_table").html(row.html());

这将是for循环。我已经为样本放了一行.. 帮助我动态更新我的行

1 个答案:

答案 0 :(得分:0)

我已更改此行

$("#cart_table").html(row.html());

$('#cart_table tr:last').after(row); 

它有效..

感谢Luke Bennett