I have this modal that opens when clicking a button, but the close button won’t work, here’s my HTML and JS code. Hope you can help me.
HTML
<div class="portfolio-modal flex-center">
<div class="portfolio-modal-body">
<i class="fas fa-times portfolio-close-btn"></i>
<h3>My MovieDB</h3>
<img src="https://pics.me.me/thumb_newspaper-dad-charizard-meme-is-not-amused-53734653.png" alt="">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptate, debitis ipsum quo sint nulla aspernatur illum</p>
</div>
</div>
JS
const portfolioModals = document.querySelectorAll(".portfolio-modal");
const imgCards = document.querySelectorAll(".img-card");
const portfolioCloseBtns = document.querySelectorAll(".portfolio-close-btn");
let portfolioModal = function(modalClick) {
portfolioModals[modalClick].classList.add("active");
}
imgCards.forEach((imgCard, i) => {
imgCard.addEventListener("click", () => {
portfolioModal(i);
});
});
portfolioCloseBtns.forEach((portfolioCloseBtn) => {
portfolioCloseBtn.addEventListener("click", () => {
portfolioModals.forEach((portfolioModalView) => {
portfolioModalView.classList.remove("active");
});
});
});