I need to show only one element at a time when a link is clicked on. Right now i'm cheating by hiding everything again and then toggling the element clicked on. This works, unless i want EVERYTHING to disappear again. Short of adding a "Hide All" button/link what can i do? I would like to be able to click on the link again, and hide it's content.
EDIT: Pseudo's code would have worked, but the html here mistakenly led you to believe that all the links were in one div. instead of tracking down where they all were, it is easier to call them by their ID.
Here's what i have so far:
$(document).ready(function(){
//hides everything
$("#infocontent *").hide();
//now we show them by which they click on
$("#linkjoedhit").click(function(event){
$("#infocontent *").hide();
$("#infojoedhit").toggle();
return false;
});
$("#linkgarykhit").click(function(event){
$("#infocontent *").hide();
$("#infogarykhit").toggle();
return false;
});
});
and the html looks like:
<div id="theircrappycode">
<a id="linkjoedhit" href="">Joe D</a><br/>
<a id="linkgarykhit" href="">Gary K</a>
</div>
<div id="infocontent">
<p id="infojoedhit">Information about Joe D Hitting.</p>
<p id="infogarykhit">Information about Gary K Hitting.</p>
</div
there are about 20 links like this. Because i am not coding the actual html, i have no control over the actual layout, which is horrendous. Suffice to say, this is the only way to organize the links/info.