I would use the following two JavaScript functions to hide and show the elemets:
function hideAllInfo() {
var aSpans = document.getElementsByTagName("span");
for (i = 0; i < aSpans.length; i++) {
aSpans[i].style.display = 'none';
}
}
function showInfo(id) {
hideAllInfo();
document.getElementById(id).style.display = 'block';
return false;
}
Then in the HTML I would do something like:<div>
<a onclick="return showInfo('Google');">What is Google</a>
</div>
<div>
<a onclick="return showInfo('Yahoo');">What is Yahoo</a>
</div>
<span id="Google" style="display:none">
<div>Here would be some info about Google.</div>
<a href="http://www.google.com">Go to Google</a>
</span>
<span id="Yahoo" style="display:none">
<div>Here would be some info about Yahoo.</div>
<a href="http://www.yahoo.com">Go to Yahoo</a>
</span>
When you click on a link the first thing the showInfo function does is call the hideAllInfo function. The hideAllInfo function resets all the information areas back to non-display. showInfo then sets the selected areas display property so it will display. The nice thing about this approch is that you can add as many links and information areas as you want without having to change the JavaScript code.
Bookmarks