I have a list of items I'm displaying with the html below. Each item has a hidden div with more details about the item. I have made it so if I click the onclick link it shows the div for that specific item. What I want to know is how I would make it hide the div I just opened if I use the onclick to display another items details? Also how could I make it toggle itself when the same onclick is clicked? My knowledge of javascript is somewhat limited so any help would be appreciated. Thanks!
HTML
<div>Item Name <a onclick="FullItemDetails(123)">Full Item Details</a></div>
<div>other stuff</div>
</div>
<div id="FullItemDetails_123" style="display: none;"></div>
And JAVASCRIPT
<script>
function FullItemDetails(item_id) {
document.getElementById("FullItemDetails_" + item_id).style.display = "block";
}
</script>
Each div with the extra info has a FullItemDetails_ ID followed by the items unique ID.