0

I have made some bubbles on my site and I want to let the clicked bubble dissapear. for one or another reason it keeps telling 'bellen.addEventListener is not a function'. I don't understand what's wrong with my code.

const bellen = document.querySelectorAll(".bubble");

bellen.addEventListener("click", () => {
  bellen.style.display = "none";
  console.log("hey");
});
<div id="background-wrap">
  <div class="bubble x1"></div>
  <div class="bubble x2"></div>
  <div class="bubble x3"></div>
  <div class="bubble x4"></div>
  <div class="bubble x5"></div>
  <div class="bubble x6"></div>
  <div class="bubble x7"></div>
  <div class="bubble x8"></div>
  <div class="bubble x9"></div>
  <div class="bubble x10"></div>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
stavros
  • 29
  • 5
  • `document.getElementById("background-wrap").addEventListener("click", (e) => { const tgt = e.target; if (tgt.matches(".bubble")) { console.log(\`Popping ${tgt.id}\`); tgt.hidden = true; });` – mplungjan Feb 15 '23 at 15:11

0 Answers0