为什么我把2个例子写在1个html文档里就不行了
<!DOCTYPE html>
<html>
<style>
.holiday{ font-size:16px ;}
.holiday #hdate{ font-size: 20px; color: red;}
</style>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="showtime">
在这里显示时间
</div>
<p class="holiday">距离放假还有<span id="hdate"></span>天</p>
<script>
window.onload = function st(){
var year = new Date().getFullYear();
var month = new Date().getMonth()+1;
var day = new Date().getDate();
var w = new Date().getDay()
var cweek =new Array(7)
cweek[0]="星期日"
cweek[1]="星期一"
cweek[2]="星期二"
cweek[3]="星期三"
cweek[4]="星期四"
cweek[5]="星期五"
cweek[6]="星期六"
var h = new Date().getHours();
var m = new Date().getMinutes();
var s = new Date().getSeconds();
document.getElementById("showtime").innerHTML =year+"年"+month+"月"+day+"日" +cweek[w]
+ h +"时" + m +"分"+ s+"秒";
setTimeout(st,500)
}
window.onload=function ht()
{
var endtime = new Date(2016,6,29)
var todaytime = new Date();
var lefttime = endtime - todaytime
}
</script>
</body>
</html>