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