love_kim3176858
2017-10-24 12:06
<script type="text/javascript"> var mydate = new Date(); var timestr = ''; timestr = mydate.getFullYear()+"年"; timestr += mydate.getMonth()+1+"月"; timestr += mydate.getData()+"日"; var day = mydate.getDay(); var week = ''; switch(day){ case 0: week = '星期日'; break; case 1: week = '星期一'; break; case 2: week = '星期二'; break; case 3: week = '星期三'; break; case 4: week = '星期四'; break; case 5: week = '星期五'; break; case 6: week = '星期六'; break; } timestr += " "+week; document.write(timestr); var arrstr = "小明:87; 小花:81; 小红:97; 小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76"; var arr = arrstr.split(";"); var sum = 0; var av = 0; for (var i = 0; i < arr.length; i++) { var index = arr[i].indexOf(":"); var a = parseInt(arr[i].substr(index+1,2)); sum += a; } av = sum/arr.length; document.write("--班级总分为:"+av); </script>
timestr += mydate.getDate()+"日";
是getDate()不是getData()
关键字一般都会变色的,敲完之后看下有没有变
JavaScript进阶篇
468195 学习 · 21891 问题
相似问题