I've implemented a "Tab" functionality inside one of my pages. Following is the code:
$(document).ready(function() {
$('ul.tabs li').click(function() {
var tab_id = $(this).attr('data-tab');
$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');
$(this).addClass('current');
$("#" + tab_id).addClass('current');
})
})
.tab.current {
color: red;
}
.tab-content {
display: none;
}
.tab-content.current {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<ul class="tabs">
<li class="tab current" data-tab="tab-1">Overview</li>
<li class="tab" data-tab="tab-2">Get started</li>
</ul>
<article id="tab-1" class="tab-content current">TAB 1</article>
<article id="tab-2" class="tab-content">TAB 2</article>
It works perfect, but only in this page. What I want to achieve is to have links from another page (index.html) to this one (features.html) with a specific tab selected.
Is there any simple way to update my function to achieve this behavior?