Last active
August 28, 2022 22:06
-
-
Save hmbashar/1b2f70d845a6fcb8452cde320d3a61a9 to your computer and use it in GitHub Desktop.
UL List Item Serial Automatically Alphabetically
This file contains hidden or 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
(function($){ | |
$( document ).ready(function() { | |
var mylist = $('#allstate-ul-list ul'); // input your selector | |
var listitems = mylist.children('li').get(); | |
listitems.sort(function(a, b) { | |
return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase()); | |
}); | |
mylist.empty().append(listitems); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment