We can use the builtin summary & detail html tags to save our time and effort.
@GreeDeus Жыл бұрын
i done something similar but how you keep open just the one you clicked, and the other one(s) closed?
@gotreehouse Жыл бұрын
There are many ways to do this! One way to only open one accordion at a time is that you'll want to grab a collection of accordion elements and remove the active class on all of them and then add the active class on the clicked accordion.
@Knards2 жыл бұрын
Thanks!
@spiritualforce Жыл бұрын
Thank you
@ahmedadennoor49542 жыл бұрын
so helpfull bro keep going i alos want to be developer
@jesusserna9415 Жыл бұрын
Thanks!! I didnt know how to do this component, im still learning js => the only part that i modified was (if/else) with ternary operator : let btnsIcon = accordion.querySelector("button"); btnsIcon.textContent === "+" ? (btnsIcon.textContent = "-") : (btnsIcon.textContent = "+");
@gotreehouse Жыл бұрын
Love your use of a ternary! Very nice alternative!