I am using this code on my forum postbit. I am trying to have a div element reveal some text for each user but I can only get it working for the first user.
The other divs are always open. I am not sure where I'm going wrong with it.
function toggleDiv(id) {
$("#" + myContent).toggle();
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="javascript:toggleDiv('myContent');">
<i style="color: #000; font-size: 13px;" class="fa fa-chevron-down fa-fw"></i>
</a>
<div class="animated fadeIn" id="myContent" style="padding: 10px;">
Reveal text here.
</div>
Your function takes a parameter id, but you're using myContent i the body of the function. Like this it works: