diff --git a/js/likes_counter.js b/js/likes_counter.js index 18c1d14..30737eb 100644 --- a/js/likes_counter.js +++ b/js/likes_counter.js @@ -1,14 +1,12 @@ // COMPTE LES LIKES : INCREMENTE / DECREMENTE DE 1 AU CLIC const likesCount = () => { - const likes = document.querySelectorAll('.gallery__likes--icon'); - // likes.addEventListener('clic', handleEvent); + const likes = document.querySelectorAll('.gallery__likes--btn'); const totalCounter = document.querySelector('#total-likes'); for (let i = 0; i < likes.length; i++) { let like = likes[i]; like.setAttribute("aria-label", "likes") - // handleEvent = () => { - like.addEventListener('click', () => { + like.addEventListener('click', (event) => { like.classList.toggle('selected'); let likeCounter = like.parentElement.children[0]; // au click sur "like", l'input "counter" prend le focus if (like.classList.contains('selected')) { @@ -22,6 +20,10 @@ const likesCount = () => { likeCounter.style.color = '#901c1c'; totalCounter.value--; // decremente de 1 le compteur global de likes } + // ACCESSIBILITE + // navigation clavier sur btn "like" : "entree" = "click" + if (event.keycode == 13) like.click(); }); } }; +