Skip to content

Commit

Permalink
Fix(JS) Remove listener
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Dec 14, 2023
1 parent 9f4d156 commit 17212b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/js/12-exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ const listItem = document.querySelector('.js-list');

listItem.addEventListener('click', onCardClick);

async function onCardClick(e) {
if (!e.target.closest('.filters__item')) {
async function onCardClick(event) {
if (!event.target.closest('.filters__item')) {
return;
}
listItem.removeEventListener('click', onCardClick);
const item = e.target.closest('.filters__item');
const item = event.target.closest('.filters__item');

const filter = item.children[0].innerText.toLowerCase();
const name = item.children[1].innerText.toLowerCase();
Expand Down

0 comments on commit 17212b5

Please sign in to comment.