how can i use jQuery to show/hide the same div area… essentially swapping out content?
here is what i have so far, and i cant figure out how to hide the previous content and replace it with the new content:
<script type="text/javascript">
$(document).ready(function(){
$('.content').hide();
$('a').click(function(){
$('.content').show('slow');
});
//then hide previous content
});
</script>
<a href="#" id="a-link">A</a>
<a href="#" id="b-link">B</a>
<div class="start-content" id="a">
content here
</div>
<div class="content" id="b">
content here
</div>
If you wrap the contents in a div, this would be a bit easier, like this:
And this in jQuery:
Since you have a convention with your IDs though, you can use that, either give you links a class, or wrap them as well, like this:
Then you could use a single event handler for all your links like this: