@@horstmann
Aber inzwischen habe ich so die Sache geloest
document.querySelectorAll(".card__inner").forEach(c => c.onclick = function () { this.classList.toggle('is-flipped') })
Du solltest nicht onclick
verwenden, sondern addEventListener
. Ein Grund ist, dass addEventListener
– wie der Name schon sagt – EventListener hinzufügt und nicht andere möglicherweise vorhandenen überschreibt.
Außerdem: sprechende Variablen verwenden:
- nicht
c
, sonderncard
- nicht
e
, sondernevent
(gilt auch für die Beispiele im verlinkten Artikel von David Walsh)
😷 LLAP
--
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon