刚刚启动java脚本,需要帮助运行这两个脚本,似乎只有一个运行

时间:2017-04-12 14:10:11

标签: javascript html

需要帮助运行这两个脚本,只有一个似乎运行,我得到一个工作的名称,但它只是停止运行。帮助将不胜感激。我一直在使用java和C ++,所以这对我来说自然很困惑。感谢

{{1}}

1 个答案:

答案 0 :(得分:2)

您在这一行错过)document.write ("You should be in preschool";

@Albzi,@ Alex K.和@Henry在评论中也指出了其他一些错误。这些家伙帮了很多忙。

代码更改:

  • 修正了此行中)的问题:document.write ("You should be in preschool";
  • if(my age > 4 && <18)替换if (myAge>4 && myAge<18)。下面一行也是如此。
  • my age
  • 替换myAge
  • 更正拼写

&#13;
&#13;
body {
  font-size: 1.6em;
}

.hidden {
  display: none;
}

.show {
  display: inline!important;
}

button {
  border: 2px solid black;
  background: #E5E4E2;
  font-size: .5em;
  font-weight: bold;
  color: black;
  padding: .8em 2em;
  margin-top: .4em;
}
&#13;
<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <script src="jstut.js"></script>
</head>

<body>
  <p id="sayHello"></p>

  <script>
    var yourName = prompt("What is your name?");
    if (yourName != null) {
      document.getElementById("sayHello").innerHTML = "Hello " + yourName;
    } else {
      alert("Please enter your name correctly");
    }
  </script>

  <script>
    var myAge = prompt("What is your age?");
    if (myAge < 4) {
      document.write("You should be in preschool");
    } else if (myAge > 4 && myAge < 18) {
      document.write("You should be in public private school");
    } else if (myAge > 18 && myAge < 24) {
      document.write("You should be in college");
    } else {
      document.write("You're in the work force now");
    }
  </script>
</body>

</html>
&#13;
&#13;
&#13;