您好我正在尝试对表进行排序,当替换排序的tbody时,我失去了css样式。
<table id= "pcaHistory" class="pcaTransactionsTable claim-list-table" style="margin-left: 0px">
<tbody><tr class="top-row bottom-row" style="cursor: default">
<td class="date-cell">{{transactionDate}}</td>
<td class="transaction-cell">{{type}}</td>
<td class="transaction-cell">{{icn}}</td>
<td class="balance-before-cell">{{balanceBeforeTransaction}}</td>
<td class="amount-cell">{{amount}}</td>
<td class="balance-after-cell">{{balanceAfterTransaction}}</td>
</tr>
在js中,我使用以下内容 -
var $tbody = $('#pcaHistory tbody');
var $tbody = $tbody.find('tr').sort(function(a,b){
var tda = $(a).find('.date-cell').text();
var tdb = $(b).find('.date-cell').text();
// if a < b return 1
if(SORT === 0)
return new Date(tda) - new Date(tdb);
else
return new Date(tdb) - new Date(tda);
});
$('#pcaHistory tbody').replaceWith($tbody);
当我这样做时,它会丢失来自class=claim-list-table
css
.claim-list-table {
tbody {
border-bottom: 1px solid @gray;
}
我该如何解决这个问题?