Skip to content

Commit

Permalink
added remove button
Browse files Browse the repository at this point in the history
  • Loading branch information
KANDUKURIsaikrishna authored and lcrojano committed Oct 22, 2024
1 parent 1525028 commit d2c0176
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/favs.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const setFavs = function () {
<div class="info flex-col " >
<p><strong>${gif.authorName || 'autor'}</strong></p>
</div>
<button class="remove-fav-btn">Remove from Favorites</button>
</figcaption>
`;
let text, description;
Expand All @@ -76,6 +77,12 @@ const setFavs = function () {
text = 'Check out this amazing Gif!';
description = 'Check out this amazing Gif!';

figure.querySelector('.remove-fav-btn').addEventListener('click', (e) => {
removeFav(gif.imageUrl);
figure.remove(); // Remove the GIF from the DOM
});

fragment.appendChild(figure);
modal.addEventListener('click', (e) => {
if (e.target.id === 'fav') {
removeFav(url);
Expand Down

0 comments on commit d2c0176

Please sign in to comment.