Skip to content

Instantly share code, notes, and snippets.

@hmbashar
Last active August 28, 2022 22:06
Show Gist options
  • Save hmbashar/1b2f70d845a6fcb8452cde320d3a61a9 to your computer and use it in GitHub Desktop.
Save hmbashar/1b2f70d845a6fcb8452cde320d3a61a9 to your computer and use it in GitHub Desktop.
UL List Item Serial Automatically Alphabetically
(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