Skip to content

Instantly share code, notes, and snippets.

@Reine0017
Created April 9, 2022 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reine0017/819540cc6ee31eac647fd42503500d78 to your computer and use it in GitHub Desktop.
Save Reine0017/819540cc6ee31eac647fd42503500d78 to your computer and use it in GitHub Desktop.
confetti-button.js
const createConfetti = () => {
const confettiBtn = document.querySelector(".confettiButton")
const words = document.querySelector("p")
if(words){
confettiBtn.textContent = "Click me for confetti!"
confettiBtn.style.backgroundColor = "aquamarine"
words.remove()
return
}
const para = document.createElement('p');
para.textContent = "You've clicked the confetti button!";
document.body.appendChild(para);
const jsConfetti = new JSConfetti()
jsConfetti.addConfetti()
confettiBtn.textContent = "Hide Words"
confettiBtn.style.backgroundColor = "skyblue"
}
const confettiBtn = document.querySelector(".confettiButton")
confettiBtn.addEventListener("click",createConfetti)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment