'Multiple buttons function to expand and hide div section with javascript
Hope everyone is having fun on this fun (or frustrating 😂 like me) coding day. So, I came across a problem and was hoping someone could help guide me to the right solution. I want to set it so that when I click on the “read more” button, it adds the “active” class and would expand the paragraphs. I was able to do a loop function for multiple buttons on the page, but when I click on one, it affects all the buttons. I know this is a looping problem but I have not figured out a way to solve it. What I’m trying to do is basically only have the button I click on add the class, without it working on all the buttons on the webpage. I intend to add more buttons to the page, so if anyone has a better solution or knows of a looping method (cause I’m pretty sure the looping I’m using is the wrong way), please help. Please see the video for what I mean when I click on one button, both buttons get affected by it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
