I have a card container with multiple cards inside. When I click on a card, it flips to show the back. However, I want the previously clicked card to close when I click on another card. My current code is not working as expected despite trying various Jquery and JavaScript methods.
Although the flip effect works on hover, I specifically need it to trigger on click. Furthermore, the issue persists in which the previously flipped card remains open even after clicking on a new card.
If you have any suggestions or solutions, please advise. You can view the code on this fiddle: https://jsfiddle.net/hmt8n6x5/1/
HTML
<div class="row whole-shop-container shop-body show-products prod-content clearfix card-container">
<div class="col-lg-6 col-md-6 col-sm-6 product-item">
...
CSS
.card {
background-color: transparent;
border: 0;
}
...
const card = document.querySelectorAll('.card');
const front = document.querySelectorAll('.card-flip .card-front');
...