Hello. I have a page that is displaying facebook news feeds and I have multiple instances of the same id's and classes in the HTML for display. For each single feed from facebook, I would like to be able to click an "open" button and have a hidden div appear under it which displays comments and such. I know how to do this for 1 feed using javascript, but how do I do it for multiple feeds with the same id's?
The HTML looks something like this:
Code:
<div id="facebookfeed">
Facebook Feed Info
<a onclick="opencomment()">Open Comments</a>
</div>
<div id="facebookcomments">
facebookcomments
</div>
The I have the div "facebookcomments" as display: none;. When I have one single facebook feed, I can easily have the comment display and hide, but when I have multiple instances of the above html, the javascript only opens and closes the first comment box. How would I make the javascript work to open only each individual commentbox?
Here's my current basic javascript to open 1 commentdiv.
Code:
function opencomment() {
var divstyle = new String();
divstyle = document.getElementById("facebookcomments").style.display;
if(divstyle.toLowerCase()=="block" || divstyle == "")
{
document.getElementById("facebookcomments").style.display = "none";
}
else
{
document.getElementById("facebookcomments").style.display = "block";
}
}
Thank you in advance!