I have a row of links across the top of my page which are meant to act as tabs, when one is clicked I want its DIV to show and the rest to hide. I'm really not sure the best way to go about this.
What I originaly came up with:
$("#overall").click(function(){
if ($("#overall").is(":hidden"))
{
$("#hourly-div").hide("fast");
$("#daily-div").hide("fast");
$("#monthly-div").hide("fast");
$("#overall-div").show("fast");
}
});
But I found out this doesn't work well at all. Should I be checking if the CSS for the DIV is display: hidden;
?
Mark up below.
<ul class="stats">
<li><a href="#" id="overall">Overall stats</a></li>
<li class="sep">|</li>
<li><a href="#" id="hourly">Hourly Bandwidth</a></li>
<li class="sep">|</li>
<li><a href="#" id="daily">Daily Bandwidth</a></li>
<li class="sep">|</li>
<li><a href="#" id="monthly">Monthly Bandwidth</a></li>
</ul>
<div id="overall-div">
overall
</div>
<div id="hourly-div" style="display: none;">
hourly
</div>
<div id="daily-div" style="display: none;">
daily
</div>
<div id="monthly-div" style="display: none;">
monthly
</div>
I wanted the overall
div to show when a user loads the page, and the rest to be hidden until a user clicks a tab for them.
Thanks. :)