我需要打印插入我的数据库的收据,最新的收据应该在我的页面顶部。但是当我查询我的数据库时,我将所有数据存储在一个 var 中,它自然会将最早插入的数据放在我的页面顶部,我该如何反转呢?
function querySuccess(tx, results){
if(results.rows.length == 0)
{
$("#ReceiptsList").html("<p>You have no receipts captured yet</p>");
}
else
{
var s = "";
for(var i = 0; i<results.rows.length; i++)
s += "<a href='edit.html?id="+results.rows.item(i).id+"'><strong><font size = 3> " + results.rows.item(i).name +"<font></strong>" + " <font size = 1>Date:" +results.rows.item(i).date + "<font></a> ";
}
//I tried s.reverse(); but didn't work, nothing was showed on the page
$("#ReceiptsList").html(s);
}