Design comparison
Solution retrospective
i have completed this task but i have some issues. I want the percentage buttons to change when clicked(i.e add a class active),i did it i used dev tools to check if its adding the class and yes it is but it not overwriting the original color and background-color.Thats one, i also want to it to remove the class active from a button when a new button is clicked.Any suggestion on how i can go about this ?.
Community feedback
- @nelsonleonePosted almost 2 years ago
HELLO......congrats on completing this challenge....well done:🎊 🎊
Based on your second question , you can use a loop , to remove all active class, then add the active class to the target element.
Element.addEventListner('click',(e)=> { document.querySelectorAll('.active').forEach(element = element.classList.remove.('active') e.target.classList.add('active') }
The e.targetsimply means the element that caused /invoked the function.
Hope this comment was helpful ,have fun coding
Marked as helpful0@nelsonleonePosted almost 2 years ago@buk-ola01 you are welcome , you can mark the comment as helpful , if it worked out for you
0 - @buk-ola01Posted almost 2 years ago
I have been able to solve the first problem. Left with the second
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord