Set up CSS to do the highlighting and switching for you:
.First .ShowFirst { border: 1px solid #000; }
.First .SecondContent { display: none; }
.Second .ShowSecond { border: 1px solid #000; }
.Second .FirstContent { display: none; }
Javascript to bind click events that change the class name of the parent:
$(function() {
$('.ShowFirst').Click(function(){
$('#Parent').attr('className', 'First');
return false;
});
$('.ShowSecond').Click(function(){
$('#Parent').attr('className', 'Second');
return false;
});
});
The class name of the parent decides which link is highlighted and which content is shown. Here the first content is shown from start:
<div id="Parent" class="First">
<a class="ShowFirst" href="#">Show first</a>
<a class="ShowSecond" href="#">Show second</a>
<div class="FirstContent">1</div>
<div class="SecondContent">2</div>
</div>
(As a bonus it won't show both content while loading and hide one when the loading is done. Only one of the content divs are visible from start.)