lab-development-imb/web/12/labor/loesungen/uebung03.js

24 lines
605 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const kalender = document.getElementById("kalender");
const heuteTag = new Date().getDate();
const heuteMonat = new Date().getMonth();
const geschenk = "\u{1F381}";
const baum = "\u{1F384}";
for (let i = 1; i <= 24; i++) {
const tuer = document.createElement("div");
tuer.classList.add("tuerchen");
tuer.textContent = i;
tuer.addEventListener("click", () => {
if (i <= heuteTag && heuteMonat === 11) {
tuer.classList.add("offen");
tuer.textContent = geschenk;
} else {
alert("Noch schläft das Türchen wie ein Geschenk unter dem " + baum)
}
});
kalender.appendChild(tuer);
}