我正在尝试制作交易明细页,我如何使交易表上的新输入表行在上一个行之前排序?我使用节点,mongo,猫鼬和javascript和ejs
<section id="transactions">
<div class="mx-5 my-5">
<table>
<tr>
<th>Transaction ID</th>
<th>Beneficiary Details</th>
<th>Timestamp</th>
<th>More</th>
</tr>
<% transactions.forEach(function(transaction) { %>
<tr>
<td><%= transaction._id %></td>
<td> <%= transaction.beneficiaryName %> <%= transaction.beneficiaryBank %> <%= transaction.beneficiaryAccountNumber %> <%= transaction.transferAmount %></td>
<td><%= transaction.time %></td>
<td><a href="<%= transaction._id %>"></a></td>
</tr>
<% }) %>
</table>
</div>
如果您是根据交易生成列表,而我猜它是对象数组,则可以使用:
transactions.unshift({<newObject>})
将其添加到数组的开头
如果要使用JQuery进行操作,请使用:
$('table > tbody > tr:first').before('<tr><td>Stuff</td></tr>');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句