I have a few nested divs, like so:
<div class="person" onClick="revealBio()">
<div class="name">...some name</div>
<div class="role">...some role</div>
<div class="bio">...some bio</div>
</div>
In my CSS, I have the bio hidden (just like an accordion). When that person clicks onto any member's info, I want to expand to show the bio (through a change in css). However, the target on my click is too specific. I want it to return to me the person card ("person" div) that was clicked, but it also just returns to me the name and role if those are specifically clicked.
Here is the vanilla javascript that I'm using:
function revealBio(){
document.addEventListener('click', function(e) {
var revealThisBio = e.target;
revealThisBio.classList.toggle('reveal-bio')
})
}
I would like for it to return to me:
<div class="person" onClick="revealBio()">
<div class="name">...some name</div>
<div class="role">...some role</div>
<div class="bio">...some bio</div>
</div>
so that I can toggle a class onto the person class that reveals the bio info. Is there a way to have my target be less specific?
Thanks!