為什么我的代碼沒(méi)點(diǎn)擊后沒(méi)反應(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("請(qǐng)輸入你的成績(jī):"); ? ?
if(score>=90) { document.write("你很棒");}
else if(score>=75) { document.write("還不錯(cuò)"); }
else if(score>=60) { document.write("繼續(xù)努力"); }?
else() { document.write("要加油了"); }
}
? ?
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" /></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("請(qǐng)輸入你的成績(jī):"); ? ?
? ? if(score>=90) { document.write("你很棒");}
? ? else if(score>=75) { document.write("還不錯(cuò)"); }
? ? else if(score>=60) { document.write("繼續(xù)努力"); }?
? ? else { document.write("要加油了"); }
}
? </script>
</head>
<body>
? ? <input name="button" type="button" onclick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" /></body>
</html>
2017-08-04
題主在最后一個(gè)else的后面多了一對(duì)括號(hào),完整如下:
<!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("請(qǐng)輸入你的成績(jī):"); ? ?
????if(score>=90) { document.write("你很棒");}
????else if(score>=75) { document.write("還不錯(cuò)"); }
????else if(score>=60) { document.write("繼續(xù)努力"); }?
????else() { document.write("要加油了"); }
????}
????? ?
????? </script>
????</head>
????<body>
????? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" />
????</body>
</html>
2017-08-04
else后面不需要那個(gè)括號(hào)
2017-08-03
問(wèn)題出在這里var score =prompt("請(qǐng)輸入你的成績(jī):"); ??
改為
var score;
score =?? prompt("請(qǐng)輸入你的成績(jī)")??