Can VueJS and vanilla JS be used to collapse specific divs among many?
I have information contained in separate card elements that include a title and a body. My goal is to make the body of each card expand or collapse when the respective title is clicked.
I am currently utilizing VueJS and prefer to avoid incorporating JQuery for now, focusing on pure JavaScript instead.
You can view an example of what I mean by checking out this example. Please note that I acknowledge the issue with using the same ID for multiple elements - it was simply done quickly for demonstration purposes.
<div class="section">
<div class="title" @click="toggle"><span class="toggleIcon" id="toggleIcon">{{toggleIcon}}</span>Toggle This Section</div>
<hr/>
<div class="body" id="toggle">
<img style="height:100px" src="https://cdn.vox-cdn.com/thumbor/Pkmq1nm3skO0-j693JTMd7RL0Zk=/0x0:2012x1341/1200x800/filters:focal(0x0:2012x1341)/cdn.vox-cdn.com/uploads/chorus_image/image/47070706/google2.0.0.jpg">
</div>
</div>
The challenge I am facing right now is being able to collapse individual divs instead of all at once.