1 year ago
#387417
Phong Hoang
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.
javascript
button
foreach
hidden-field
0 Answers
Your Answer