diff --git a/halloween.js b/halloween.js index 979c7dd..1eea0af 100644 --- a/halloween.js +++ b/halloween.js @@ -87,11 +87,16 @@ function addRandomSymbols(count) { for (let i = 0; i < count; i++) { // create a new halloween elements - const halloween = document.createElement('div'); - halloween.classList.add('halloween'); + const halloweenDiv = document.createElement("div"); + halloweenDiv.className = "halloween"; // pick a random halloween symbol - halloween.textContent = images[Math.floor(Math.random() * images.length)]; + const imageSrc = images[Math.floor(Math.random() * images.length)]; + const img = document.createElement("img"); + img.src = imageSrc; + + halloweenDiv.appendChild(img); + // set random horizontal position, animation delay and size(uncomment lines to enable) const randomLeft = Math.random() * 100; // position (0% to 100%) @@ -100,11 +105,11 @@ function addRandomSymbols(count) { const randomAnimationDelay2 = Math.random() * 5; // delay (0s to 5s) // apply styles - halloween.style.left = `${randomLeft}%`; - halloween.style.animationDelay = `${randomAnimationDelay}s, ${randomAnimationDelay2}s`; + halloweenDiv.style.left = `${randomLeft}%`; + halloweenDiv.style.animationDelay = `${randomAnimationDelay}s, ${randomAnimationDelay2}s`; // add the halloween to the container - halloweenContainer.appendChild(halloween); + halloweenContainer.appendChild(halloweenDiv); } console.log('Random halloween symbols added'); }