From 1bb387cb5c6a0efe0e32bc05d79db619018930c2 Mon Sep 17 00:00:00 2001 From: Duc Cao Date: Thu, 8 Oct 2020 14:32:03 +0700 Subject: [PATCH] HTMLcollection with array and how to select next element on the same tree --- practice/04/try/src/js/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/practice/04/try/src/js/index.js b/practice/04/try/src/js/index.js index e69de29..941dfcb 100644 --- a/practice/04/try/src/js/index.js +++ b/practice/04/try/src/js/index.js @@ -0,0 +1,10 @@ +(function() { + + const buttons = document.getElementsByClassName('button'); + // console.log(buttons); + [...buttons].forEach(element => { + element.addEventListener('click', () => { + element.nextElementSibling.classList.toggle('is-active'); + }); + }); +})(); \ No newline at end of file