<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
<script type="text/javascript">
function rec() {
var score =prompt("请输入你的成绩:");
if(score>=90) { document.write("你很棒");}
else if(score>=75) { document.write("还不错"); }
else if(score>=60) { document.write("继续努力"); }
else() { document.write("要加油了"); }
}
</script>
</head>
<body>
<input name="button" type="button" onClick="rec()" value="点击我,对成绩做评价!" /></body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
<script type="text/javascript">
function rec() {
var score =prompt("请输入你的成绩:");
if(score>=90) { document.write("你很棒");}
else if(score>=75) { document.write("还不错"); }
else if(score>=60) { document.write("继续努力"); }
else { document.write("要加油了"); }
}
</script>
</head>
<body>
<input name="button" type="button" onclick="rec()" value="点击我,对成绩做评价!" /></body>
</html>
题主在最后一个else的后面多了一对括号,完整如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
<script type="text/javascript">
function rec() {
var score =prompt("请输入你的成绩:");
if(score>=90) { document.write("你很棒");}
else if(score>=75) { document.write("还不错"); }
else if(score>=60) { document.write("继续努力"); }
else() { document.write("要加油了"); }
}
</script>
</head>
<body>
<input name="button" type="button" onClick="rec()" value="点击我,对成绩做评价!" />
</body>
</html>
else后面不需要那个括号
问题出在这里var score =prompt("请输入你的成绩:");
改为
var score;
score = prompt("请输入你的成绩")