一个简单的If ... else块.为什么什么都不做?

noo*_*lla 0 javascript

 <html>
    <head></head>
    <body>
     <script type = "text/javascript">
      var x = 5;
      var y = 8;
      if (x < 6)
      {
       document.write("They are equal");
      }
      else
      {
       document.write{"They are NOT equal");
      }
     </script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Cha*_*ion 12

我认为你有一个语法错误:

document.write{"They are NOT equal");
Run Code Online (Sandbox Code Playgroud)

应该

document.write("They are NOT equal");
Run Code Online (Sandbox Code Playgroud)