I've been trying to make divs where I show more info when I click on the div, but I also want to do the same thing for different divs that have different info. (like a music discography).
When I click on the div, it works fine, but when I click on all the other divs, they all fire the first jQuery function from the first div only and show the same info as the first div. This is because they're all named the same, I assume. But I was wondering how I could go about firing the same function, but without changing things around too much or making a new function for each div? I'd like to keep my code as DRY as possible.
$(function() {
$('#about-section').hide();
$('.description').click(function() {
$('#about-section') .toggle(1000);
})
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<img class="card-img-top" src="images/album2.jpeg">
<div class="content">
<div class="description">
The First Album[1989]
</div>
</div>
<div id="about-section">
<p id="p1"><img class="float-left" src="images/album2.jpeg" style="width: 500px; height:500px"></p>
<p class="album">The First Album[1989]</p>
<p>bands’ classic first record, produced by Mellisa Madrid with Floor, Jake Baker, Keifer Leblanch and Adrian Sherwood.</p>
<div id="albumlist">
<p>Tracklist </p>
<ol class="albumlist">
<li>Yes</li>
<li>No</li>
<li>Idk</li>
<li>Can you repeat the question?</li>
</ol>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<img class="card-img-top" src="images/album1.jpg">
</div>
<div class="content">
<div class="description">
The Second Album[1990]
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-5 mb-4 shadow-sm">
<img class="card-img-top" src="images/town.jpg">
</div>
<div class="content">
<div class="description">The Third Album[1990]</div>
</div>
</div>