Discuss / JavaScript / 终于通过验证了

终于通过验证了

Topic source

vi几

#1 Created at ... [Delete] [Delete and Lock User]
var ul=$("#test-div ul");
var arr=["Pascal","Lua","Ruby"];
for(var i=0;i<3;i++){
   ul.append("<li><span>"+arr[i]+"</span></li>");
}

var aLi=ul.find("li");
aLi.sort(function(a,b){
   if($(a).text()>$(b).text()){
      return 1;
   }else{
      return -1;
   }
});
aLi.appendTo(ul);

  • 1

Reply