The following code successfully toggles individual divs, but it displays active divs in a stack when toggling. I am trying to achieve the functionality of "showing only one at a time". Any suggestions?
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
<ul class="post-advanced-menu">
<li><a href="#" onclick="toggle_visibility('source');">Source</a></li>
<li><a href="#" onclick="toggle_visibility('share');">Share</a></li>
<li><a href="#" onclick="toggle_visibility('report');">Report</a></li>
</ul>
<div id="post-advanced-content">
<div id="source" style="display: none;">Source</div>
<div id="share" style="display: none;">Share</div>
<div id="report" style="display: none;">Report</div>
</div>
Thank you,