add div if
This commit is contained in:
@@ -108,8 +108,13 @@ function createExplosion(x, y) {
|
||||
|
||||
// Function for the firework with trail
|
||||
function launchFirework() {
|
||||
const fireworkContainer = document.querySelector('.fireworks');
|
||||
if (!fireworkContainer) return;
|
||||
const fireworkContainer = document.querySelector('.fireworks') || document.createElement("div");
|
||||
|
||||
if (!document.querySelector('.fireworks')) {
|
||||
fireworkContainer.className = "fireworks";
|
||||
fireworkContainer.setAttribute("aria-hidden", "true");
|
||||
document.body.appendChild(fireworkContainer);
|
||||
}
|
||||
|
||||
// Random horizontal position
|
||||
const x = Math.random() * window.innerWidth; // Any value across the entire width
|
||||
|
Reference in New Issue
Block a user