You need to rely on the url for this and we have great frameworks like backbone.js routing or even plugins like history.js
But without this plugins u can get the hash bang from the url and apply the active styles for the list corresponds to the it.
In order to do it HTML must be kind of like this,
<ul id="ulid" class="">
<li class="">
<a href="#tab=one" id="one" class="active">text1</a>
</li>
<li>
<a href="#tab=two" id="two" class="">text2</a>
</li>
<li>
<a href="#tab=three" id="three" class="">text3</a>
</li>
<li>
<a href="#tab=four" id="four" class="">text4</a>
</li>
<li>
<a href="#tab=five" id="five" class="">text5</a>
</li>
<li>
<a href="#tab=six" id="six" class="">text6</a>
</li>
</ul>
Where active class css could be: .active{background-color: red;}
A short add on code for getting hash bang is:
function parseHashBangArgs(aURL) {
aURL = aURL || window.location.href;
var vars = {};
var hashes = aURL.slice(aURL.indexOf('#') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
var hash = hashes[i].split('=');
if(hash.length > 1) {
vars[hash[0]] = hash[1];
} else {
vars[hash[0]] = null;
}
}
return vars;
}
Then you can get run this code on page load
$('ul#ulid li a').click(function(){
$('li a').removeClass('active');
$(this).addClass('active');
});
var selectedTab = parseHashBangArgs(window.location.href).tab;
if(selectedTab){
$('li a').removeClass('active');
$('#'+selectedTab).addClass('active');
}
And its done!