<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background-origin</title>
<script type="text/javascript">
var date=new Date();
var a =date.getDay();
var t=["星期天","星期一","星期二","星期三","星期四","星期五","星期六", ]
document.write(date.getFullYear()+"/"+date.getMonth()+"/"+date.getDate()+" "+t[a]);
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var Str=scoreStr.spilt(";");
var sum=0;
for(var i=0;i<10;i++){
sum+=parseInt(Str[i].subStr(3,5));
}
document.write(sum);
</style>
</head>
<body>
</div>
</body>
</html>
上面那个是已改完的完整代码
var t=["星期天","星期一","星期二","星期三","星期四","星期五","星期六", ] 你的这一句就有两个错误。]前面多了一个,]后面少了一个;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background-origin</title>
<script type="text/javascript">
var date=new Date();
var a =date.getDay();
var t=["星期天","星期一","星期二","星期三","星期四","星期五","星期六", ]
document.write(date.getFullYear()+"/"+date.getMonth()+"/"+date.getDate()+" "+t[a]);
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var Str=scoreStr.split(";");
var sum=0;
for(var i=0;i<10;i++){
sum+=parseInt(Str[i].substr(3,5));
}
document.write(sum);
</script>
</head>
<body>
<div>
</div>
</body>
</html>
一共有四处错误:
应该是</script>.
<div>没写
spilt方法名写错了,应该是split( );
substr方法名写错了 第二个S不大写
<style>改成</script>,你前面对应的标签是script