JQuery Multiple Group Sort
I need to sort a table of users alphabetically based upon a value in a td element. I can do basic sort fine but I have 3 tbodies per user and I need them all to stick together rather then just a single one of those tbodies being sorted.
This is an example of my table:
<tbody1>
<tr><td>The Value To Base Sort On(username)</td></tr>
<tr></tr>
</tbody>
<tbody2>
<tr><t开发者_运维问答d>some other stuff</td></tr>
<tr></tr>
</tbody>
<tbody1>
<tr><td>other stuff</td></tr>
<tr></tr>
</tbody>
I need these 3 tbodies to remain linked next to each other when the table is sorted, however all 3 should be sorted based upon a value in the first tbody if that makes sense.
Here is the jQuery plugin you are looking for:
http://james.padolsey.com/javascript/sorting-elements-with-jquery/
$('#someId>li').sortElements( function(a, b){ return $(a).text() > $(b).text() ? 1 : -1; } );
精彩评论