Skip to content
Advertisement

Flipping all cards, but want to flip one by one

I am trying to flip these cards one by one, but they are flipping all together.

I believe I am missing something on my javaScript.

On the original code I am using images in front and an unordered list in back, I tried to resume it here writing only “Front” and “Back”.

JavaScript
JavaScript
JavaScript

Do you guys know what am I doing wrong?

Advertisement

Answer

Instead of flipping all elements of class .card, you can flip only the one that the button is in, using the .closest() method (which traverses UP the DOM tree until it finds an element with the specified class).

JavaScript

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement