php - jQuery Tablesorter - initial sort rows from array -
i'm trying inital sort table it's row-numbers array/variable
$list: row0=id2;row1=id0;row2=id1... <table> <tr id="0">...</tr> <tr id="1">...</tr> <tr id="2">...</tr> </table>
how can handle tablesorter rows sorted in $list?
thanks tipp or workaround :)
this possible duplicate of: how sort dom elements while selecting in jquery?
$('#myt tr').sort(function(a, b) { if (parseint(a.id) > parseint(b.id)) return 1; else return -1; }).each(function() { $('#myt').append($(this)); });
td { border: 1px solid grey; padding: 10px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table id='myt'> <tr id="8"> <td>8</td> </tr> <tr id="1"> <td>1</td> </tr> <tr id="21"> <td>21</td> </tr> <tr id="5"> <td>5</td> </tr> </table>
Comments
Post a Comment