Discuss / JavaScript / learn

learn

Topic source

4zhuma

#1 Created at ... [Delete] [Delete and Lock User]

var ul=$("#test-div ul"); var arr=[]; ["Pascal","Lua","Ruby"].forEach(x=>{ul.append('<li><span>' +x+ '</span></li>')}); var texts=ul.find("span").map(function(){ return $(this).text(); }).get(); texts.sort(); ul.find('span').each(function(index){ $(this).text(texts[index]); });


  • 1

Reply