I have created a tabbed display with html/css. I simply want to use jQuery to toggle the tabs/classes. It works perfectly but I want to make sure I'm using jQuery properly.
Here's the html structure + jQuery:
<ul id="tabs">
<li><a href="#" id="tab1" class="activetab">Tab1</a></li>
<li><a href="#" id="tab2">Tab2</a></li>
</ul>
<div id="tabcontent">
<div id="tab1content">
This is tab 1 content
</div>
<div id="tab2content">
This is tab 2 content
</div>
$("#tab1").click(function() {
$("#tabcontent > div").hide();
$("#tab1content").show();
$("#tabs > li a").removeClass().addClass("inactivetab");
$("#tab1").removeClass().addClass("activetab");
});
The jQuery you see for tab1 is repeated for each tab.