简体   繁体   中英

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><td>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; } );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM