问答详情
源自:2-4 JavaScript-提问(prompt 消息对话框)

为什么点击取消按钮和右上角的叉到要加油哦,表示不理解

<!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("你输入放入数字有误,请重新输入");

}

  }

  </script>

</head>

<body>

    <input name="button" type="button" onClick="rec()" value="点击我,对成绩做评价!" />

</body>

</html>

看一看

提问者:慕粉4370907 2016-11-28 17:08

个回答

  • 慕粉htmlFish
    2016-11-28 17:36:48
    已采纳

    null和“”转换为number类型时为0

  • qq_n_70
    2016-11-28 17:38:56

    点击取消 返回是null,默认为0