案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p>点击这个按钮,获得基于时间的问候。</p>
6
7
<button onclick="myFunction()">点击这里</button>
8
9
<p id="demo"></p>
10
11
<script>
12
function myFunction()
13
{
14
var x="";
15
var time=new Date().getHours();
16
if (time<20)
17
  {
18
  x="Good day";
19
  }
20
else
21
  {
22
  x="Good evening";
23
  }
24
document.getElementById("demo").innerHTML=x;
25
}
26
</script>
27
28
</body>
29
</html>
30