為什么點擊取消按鈕和右上角的叉到要加油哦,表示不理解
<!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&&score<=100)
{
? document.write("你很棒!");
}
else if(score>=75&&score<90)
? ? {
? document.write("不錯吆!");
}
else if(score>=60&&score<75)
? ? {
? document.write("你會更棒的");
? ? }
? ? else if(score>=0&&score<60)
? ? {
? ? ? ?document.write("要加油哦");
? ? }
? ? else
{
? ? ? ?document.write("你輸入放入數(shù)字有誤,請重新輸入");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>
看一看
2016-11-28
null和“”轉換為number類型時為0
2016-11-28
點擊取消 返回是null,默認為0