案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<body>
3
4
<p>点击下面的按钮,会显示出基于今日日期的消息:</p>
5
6
<button onclick="myFunction()">点击这里</button>
7
8
<p id="demo"></p>
9
10
<script>
11
function myFunction()
12
{
13
var x;
14
var d=new Date().getDay();
15
switch (d)
16
  {
17
  case 6:
18
    x="Today it's Saturday";
19
    break;
20
  case 0:
21
    x="Today it's Sunday";
22
    break;
23
  default:
24
    x="Looking forward to the Weekend";
25
  }
26
document.getElementById("demo").innerHTML=x;
27
}
28
</script>
29
30
</body>
31
</html>
32