search

Home  >  Q&A  >  body text

Why is there a semicolon after the statement document.Write();? And window.alert() is not used?

<!DOCTYPE HTML>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>php.cn</title>
 <script type="text/javascript">
 //在<body>中输出一句话
 document.write("欢迎来到php.cn");
 window.alert("Sorry,The paassword your input is uncorrect,Please try again!")
 </script>
 </head>
 <body>
 </body>
</html>

Martin_WuMartin_Wu2451 days ago1493

reply all(4)I'll reply

  • 郭骏博

    郭骏博2018-03-20 17:38:17

    You can omit the last line, but it is not recommended

    reply
    0
  • 寻觅 beyond

    寻觅 beyond2018-03-17 23:58:36

    Characteristics of the JavaScript language:

    There is no need to add a semicolon after each statement. This is the case when only one statement is written in one line;

    If multiple statements are written in one line, each statement It is necessary to use a semicolon to separate;

    But most languages ​​require a semicolon at the end. In order to get used to it

    so, it is voluntary to add it or not, but it is recommended to add it

    reply
    0
  • 大辉狼

    大辉狼2018-03-12 18:27:17

    You don’t need to add

    , just change the line

    reply
    0
  • 路过

    路过2018-03-12 08:39:53

    You can add it or not

    reply
    0
  • Cancelreply