i have this tab-system:
$(document).ready(function(){
$('#tabs div').hide();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');
$('#tabs ul li a').click(function(){
if($(this).parent().hasClass('active')) {
/** active **/
} else {
$('#tabs ul li').removeClass('active');
$(this).parent().addClass('active');
var currentTab = $(this).attr('href');
$('#tabs div').hide();
$(currentTab).show('slide', {}, 500);
}
return false;
});
});
<div id="tabs">
<ul>
<li><a href="#tab-1">1</a></li>
<li><a href="#tab-2">2</a></li>
<li><a href="#tab-3">3</a></li>
<li><a href="#tab-4">4</a></li>
<li><a href="#tab-5">5</a></li>
</ul>
<div id="tab-1">
Content tab1
</div>
<div tab2... etc
If i add #tab-3 at the end of the URL, it should automaticly show and set tab 3 active without me have to click it.
Is this possible in a simple way?
Edited after looking at your code further –
if you code in these two lines every time the DOM is ready you are always going to see that first tab.
your going to have to check the url for a ‘#tab’ first before you decide if you should show the first tab.