Created
October 9, 2017 20:42
-
-
Save goodyis/a6fa9ff5c4809de50d84f2f3ea29a3e3 to your computer and use it in GitHub Desktop.
Alphabetically sorting table by rows, via td value using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( "div.protected-downloads" ).each( function ( index ) { | |
$dType = $( this ).data( 'type' ); | |
$combined = $dType + "_table"; | |
$( this ).find(' table tbody' ).addClass( $combined ); | |
$mylist = $( '.' + $combined ); | |
$listitems = $mylist.find( 'tr:not(".hidden")' ); | |
$listitems.sort( function( a, b ) { | |
return $( a ).text().toUpperCase().localeCompare( $( b ).text().toUpperCase() ); | |
}) | |
$.each( $listitems, function( idx, itm ) { $mylist.append( itm ); } ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment