Javascript is very similar to other languages, at least in syntax. I suspect your having trouble working with DOM. Let see if we can help.
So it sounds like you have several blocks of text that are being loaded and you are trying to get them to open or close when clicked on.
First looping through them will not open them individually it will open all them or even if did open just one it would be excess work.
Using devinemke script I will try to expand it to work for that.
First, note that "text" is the id of an element. To get that script to work with multiple elements you either need to write a different function for each block or you can pass to the function the elements id that you wish to open.
<div id="myelement" onclick="show_hide(this)">My Text</div>
Or if the button or object being clicked on is not the actual element you wish to display you can reference it
<span onclick="show_hide('myelement')">Show My Div</span>
<div id="myelement">My Text</div>
As well if you maintain a very strict architecture you could use
<span onclick="show_hide(this.nextSibling)">Show My Div</span>
<div id="myelement">My Text</div>
And then change devinemke's script like so
<script type="text/javascript" language="javascript">
function show_hide(obj)
{
state = document.getElementById(obj).style.visibility;
if (state == "hidden") {document.getElementById(obj).style.visibility = "visible";}
if (state == "visible") {document.getElementById(obj).style.visibility = "hidden";}
}
</script>
I should note also that in his script he used "visibility". I have had some issues on some browsers with it and you may what to try the "display" style.
document.getElementById(obj).style.display = "none";
document.getElementById(obj).style.display = "block";