<!DOCTYPE html>charset="utf-8"W3Cschool教程(w3cschool.cn)点击这个按钮,获得基于时间的问候。onclick="myFunction()"点击这里id="demo"function myFunction(){var x="";var time=new Date().getHours();if (time<20){x="Good day";}else{x="Good evening";}document.getElementById("demo").innerHTML=x;}