日期:2014-05-16 浏览次数:20344 次
?
<html> <head> <meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 "> <title> Javascript 排名 </title> <style type="text/css"> </style> </head> <body> <script type="text/javascript"> window.onload = function() { var orgArr = [1.2,4.5,3.44,3.44,3.6,8.9]; var arr = orgArr.slice(); arr.sort(function(a,b){ return parseFloat(a) - parseFloat(b);}); for(var i =0; i < orgArr.length;i++) { document.write("<div>" + orgArr[i] + "|"); for(var j = 0; j < arr.length; j++) { if(orgArr[i] == arr[j]) { document.write(j+1); break; } } document.write("</div>"); } }; </script> </body> </html>