為什么我的代碼沒點擊后沒反應(yīng)
<!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("繼續(xù)努力"); }?
else() { document.write("要加油了"); }
}
? ?
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" /></body>
</html>
2017-08-03
<!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("繼續(xù)努力"); }?
? ? else { document.write("要加油了"); }
}
? </script>
</head>
<body>
? ? <input name="button" type="button" onclick="rec()" value="點擊我,對成績做評價!" /></body>
</html>
2017-08-04
題主在最后一個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("繼續(xù)努力"); }?
????else() { document.write("要加油了"); }
????}
????? ?
????? </script>
????</head>
????<body>
????? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
????</body>
</html>
2017-08-04
else后面不需要那個括號
2017-08-03
問題出在這里var score =prompt("請輸入你的成績:"); ??
改為
var score;
score =?? prompt("請輸入你的成績")??