So, you want to fast revers rows in table. There is probably millions of possible solutions, but here I’ll preset my approach. Here is the code:

function reverseTableRows(tableId) {
    var table = document.getElementById(tableId),
        newTbody = document.createElement('tbody'),
        oldTbody = table.tBodies[0],
        rows = oldTbody.rows,
        i = rows.length - 1;

    while (i >= 0) {
        newTbody.appendChild(rows[i]);
        i -= 1;
    }
    oldTbody.parentNode.replaceChild(newTbody, oldTbody);
}

tableId parameter represents attribute id of HTML table element. Above code also minimizing reflow process to speed up rendering by not manipulating live DOM tree. Here is a basic example how reverse rows in table works. The code you can see in source of HTML page.

Comments

You can leave a response, or trackback from your own site.

Before you add comment see for rules.

Leave a Reply

Your email address will not be published. Required fields are marked *

0u8d4e