根据系统时间自动问好

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>

 <body>
 <button onclick='godDay()'>点我</button>
 <div id='demo'></div>
  <script>
  //根据系统时间自动问好
  document.write('点按钮会向你问好哦')
  function godDay(){
    var x='';
    var time=new Date().getHours();
    if (8<time<13)
    {
        x='上午好';
    }
    else if(13<time<17)
    {
        x='下午好' ;
    }
    else
    {
        x='晚上好';
    }
    document.getElementById('demo').innerHTML=x;
  }
  </script>
 </body>
</html>
原文地址:https://www.cnblogs.com/chenxi188/p/10528743.html