JavaScript implements simple ordering of page elements (Ul-li)
HTML page:
<inputtype= "button"value= "Show"onclick= "Show ()" /> <ulID= "UL1"> <Li>4</Li> <Li>3</Li> <Li>2</Li> <Li>1</Li> </ul>
JavaScript code
functionShow () {varUl1=document.getelementbyid ("Ul1"); //find out all our Li drops. varLis=ul1.getelementsbytagname ("Li"); //set up with a new array of drops Yes varlist=[]; varlilen=lis.length; for(vari=0;i<lilen;i++){ //This is what we add.list[i]=Lis[i]; } //sort an array of dropsList.sort (function(li1,li2) {varn1=parseint (li1.innerhtml); varN2=parseint (li2.innerhtml); returnN1-N2;//so let's do our simple comparison drip }) //and then we can appendchild our basic operation. for(varj=0;j<lilen;j++) {ul1.appendchild (list[j]);//the array is already lined up in order to drip; //some of them are very simple methods of dripping ah; //How am I going to make a drip? } }
The same code that we can apply with the drop in our table sort
JavaScript implements simple ordering of page elements (Ul-li)