我正在尝试制作一个简单的降临日历。 加载背景图片。在其上叠加24个编号图像。 单击叠加图像时,它们应更改为透明图像,以显示下面的背景图像。但只有它已达到那个日期。
这是我所拥有的一堆代码。
应检查日期有效性,然后显示提醒,或将点击的图像切换为透明图像。 我犯了多少错误?
<html>
<head>
<title> test calendar</title>
<script>
function getID(oObject) {
var ih = oObject.id;
}
</script>
<script>
function dooropen(door) {
today = new Date();
daynow = today.getDate();
monthnow = today.getMonth();
if (monthnow != 11 && monthnow != 0) {
alert("Is it Advent yet? NO. No it isn't Please come back then.");
return false;
}
if (daynow == door - 1) {
alert("A little bit early I'm afraid honey. Come back tomorrow to see what's behind that door!");
return false;
}
if (door > daynow) {
alert("Now you\'re just taking the piss. You\'ll have to wait " +
(door - daynow) + " days before that door's available!");
return false;
}
var ih = oObject.id;
image = document.getElementById(ih);
image.src = "clock2.png";
}
</script>
</head>
<style>
body {
background-image: url(img_1.jpg);
background-repeat: no-repeat;
}
</style>
<body>
<img id="imgDisp1" href="#" src="clock.png" onclick="getID(this); dooropen(1);">
<img id="imgDisp2" href="#" src="clock.png" onclick="getID(this); dooropen(2);">
<img id="imgDisp3" href="#" src="clock.png" onclick="getID(this); dooropen(3);">
<img id="imgDisp4" href="#" src="clock.png" onclick="getID(this); dooropen(4);">
<img id="imgDisp5" href="#" src="clock.png" onclick="getID(this); dooropen(5);">