Alphabetize a list using JS or jQuery

后端 未结 5 998
孤独总比滥情好
孤独总比滥情好 2020-12-18 16:32

I\'m trying to take the contents of a list, that is not in alphabetical order, then by adding each item to an array, sort them into alphabetical order and insert them back i

5条回答
  •  别那么骄傲
    2020-12-18 17:28

    You can simply do:

    $("li").each(function(i) { $(this).text(sectors[i]) });
    

    After you sorted the sectors array. Note your id's need to be unique.

提交回复
热议问题