JSP condition練習

huangqian_GX發表於2020-11-27

jsp_condition_if

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script type="text/javascript">
          var myDate=new Date()
          var time=myDate.getHours()
          if (time<12) {
            document.write("<b>早上好</b>")
          }
        </script>
</html>

jsp_condition_if_els

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script type="text/javascript">
          var d=new Date()
          var time =d.getHours ()
          if (time>20){
            document.write("<b>晚安</b>")
          }
          else if (time >8 &&time <10){
            document.write("<b>早安</b>")
          }

          else{
            document.write("<b>你好!</b>")
          }

        </script>
        </body>
</html>