為什么點擊取消了以后會輸出“要努力了!不準不填,滾回去重新來過!”這樣兩個內容
<!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>=75)
? ? {
? document.write("不錯吆!");
}
else if(score>=60)
? ? {
? document.write("要加油!");
? ? }
? ? else if(score>=0)
{
? ? ? ?document.write("要努力了!");
}
else (score=null);
{
? ?document.write("不準不填,滾回去重新來過!");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>
這是我又加了個點擊取消的內容,為什么點擊取消了以后會輸出“要努力了!不準不填,滾回去重新來過!”這樣兩個答案呢,正確應該怎么做。求教大神
2019-01-11
<!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>=75)
? ? {
? ?document.write("不錯吆!");
}
else if(score>=60)
? ? {
? ?document.write("要加油!");
? ? }
? ? else if(score>=0&&score!=null)
{
? ? ? ?document.write("要努力了!");
}
else?
{
? ? document.write("哼不準不填!");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>