<script type="text/javascriept">
function sortNum(a,b) {
return b -a;
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
</script>
为什么这个没效果啊?
楼主,<script type="text/javascriept"> javascript写错了
您的引入写错了
<script type="text/javascript"> // 你的type写错了。睁大眼睛好好看看哪儿写错了。。 window.onload = function(){ function sortNum(a,b) { return b - a; } var myarr = new Array("80","16","50","6","100","1"); document.write(myarr.sort(sortNum)); } </script>
试试上面的代码,会在页面打印出你想要的效果。