switch小例子

来源:互联网 发布:python time sleep参数 编辑:程序博客网 时间:2024/06/06 01:12

<!DOCTYPE html>

<html>


<head>

<metacharset="UTF-8">

<title></title>

</head>


<body>

<scripttype="text/javascript">

varnow = new Date();

var month = now.getMonth() + 1;

switch (month) {

case1:

case2:

case3:

console.log("春");

break;

case4:

case5:

case6:

console.log("夏");

break;

case7:

case8:

case9:

console.log("秋");

break;

case10:

case11:

case12:

console.log("冬");

break;

}

// new一个Date对象,指定日期为(2011,10,2)

vardate1 = new Date(2011,9,2);

// alert(date1.toDateString());

// 第二种方法

vardate2 = new Date();

date2.setFullYear(2011,9,2);

alert(date2);

</script>


</body>


</html>

0 0