I have this jquery code:
$(document).ready(function() {
$(".tabLink").each(function(){
if(location.hash) {
$(".tabLink").removeClass("activeLink");
$(location.hash+"-1").addClass("activeLink");
$(".tabcontent").addClass("hide")
$(location.hash+"-1").removeClass("hide")
} else {
$(".tablink").click(function(){
$(".tabLink").removeClass("activeLink");
$(this).addClass("activeLink");
$(".tabcontent").addClass("hide")
$(location.hash+"-1").removeClass("hide")
});
}
});
});
to switch between tabs, my html is:
<a href="#companyinfo" class="tabLink activeLink">Company</a>
<a href="#contacts" class="tabLink">Contacts</a>
<div class="tabcontent" id="companyinfo-1">
</div>
<div class="tabcontent" id="contacts-1">
</div>
when i choose another tab i have to click it twice to make the div show
here is a fiddle with the full code : http://jsfiddle.net/2SRZE/