求大神解釋一下。第一次對話框 輸入空白,跳出重新輸入對話框,輸入正確值后,else if 不執(zhí)行,沒有反應(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; //score變量,用來存儲用戶輸入的成績值。
score = prompt("請輸入你的成績:")??
? if(score>=90)
{
? ?document.write("你很棒!");
}
else if(score==null||score<0)
? ? {
? ? ? ? alert=prompt("請重新輸入");
? ? }? ?;
else if(score>=75)
? ? {
? ?document.write("不錯吆!");
}
else if(score>=60)
? ? {
? ?document.write("要加油!");
? ? }
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>
2019-02-13
你這步將重新輸入的值賦值給了變量 alert,當(dāng)然就沒辦法再用 if 語句判斷變量 score 的值了哦!
2019-02-10
score = prompt("請輸入你的成績:")? ? ??
這邊少個分號
{
? ? ? ? alert=prompt("請重新輸入");
? ? }? ?;
這邊又多個分號
2019-01-22
我這邊試了 你的代碼沒問題鴨
2019-01-22
<!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; //score變量,用來存儲用戶輸入的成績值。
score = prompt("輸入你的成績:","score");
if(score>=90)
{
? ?document.write("你很棒!");
}
else if(score>=75)
? ? {
? ?document.write("不錯吆!");
}
else if(score>=60)
? ? {
? ?document.write("要加油!");
? ? }
? ? else if(score<60&&score>0)
{
? ? ? ?document.write("要努力了!");
}
else
{
alert("請重新輸入");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>
2019-01-18
function rec() {
var score; //score變量,用來存儲用戶輸入的成績值。
score = prompt("請輸入你的成績:");
if (score >= 90) {
document.write("你很棒!");
} else if (score == null || score < 0) {
alert = prompt("請重新輸入");
} else if (score >= 75) {
document.write("不錯吆!");
} else if (score >= 60) {
document.write("要加油!");
} else {
document.write("太差了,從頭再來吧!");
}
}
2019-01-18
你測試的時候輸入的分數(shù)在0-60分之間吧?你沒有寫如果在這個區(qū)間要怎么做
2019-01-16
?{
? ? ? ? alert=prompt("請重新輸入");
? ? }? ?;
你這句后面多了分號呀,去掉