switch

来源:互联网 发布:免费彩票预测软件 编辑:程序博客网 时间:2024/06/07 19:22
<html>
<head>
<meta charset="utf-8">
<title>js</title>
</head>
<body>


<p>点击下面的按钮,会显示出基于今日日期的消息:</p>


<button onclick="myFunction()">点击这里</button>


<p id="demo"></p>


<script>
function myFunction()
{
var x;
var d=new Date().getDay();
switch (d)
  {
  case 2:
  case 3:
  case 4:
  case 6:
    x="Today it's Saturday";
    break;
  case 0:
    x="Today it's Sunday";
    break;
  default:
    x="Looking forward to the Weekend";
  }
document.getElementById("demo").innerHTML=x;
}
</script>
<?php
switch ($i)
{
 case 0:
 case 1:
 case 2:
  echo "i is less than 3 but not negative";
  break;
 case 3:
  echo "i is 3";
}
?>
</body>
</html>
0 0
原创粉丝点击