Here is the link to my demo: . I am attempting to make the page scroll when clicking on the vertical tab.
//script 1 $(document).ready(function(){
if (
$('ul#verticalNav li a').length &&
$('div.section').length
) {
$('div.section').css( 'display', 'none' );
//$('ul#verticalNav li a').each(function() {
$('ul#verticalNav li a').click(function() {
showSection( $(this).attr('href') );
});
// If hash found then load the tab from Hash id
if(window.location.hash)
{
// To get the div id
showSection( window.location.hash);
}
else // If no hash found then default first tab is opened
{
$('ul#verticalNav li:first-child a').click();
}
}
});
</script>
//script 2
function showSection( sectionID ) {
$('div.section').css( 'display', 'none' );
$('div'+sectionID).css( 'display', 'block' );
}
$(document).ready(function(){
if (
$('ul#verticalNav li a').length &&
$('div.section').length
) {
$('div.section').css( 'display', 'none' );
//$('ul#verticalNav li a').each(function() { // No need for each loop
$('ul#verticalNav li a').click(function() { // Use $('ul#verticalNav li a').click
showSection( $(this).attr('href') );
});
//});
if(window.location.hash) // If hash found then load the tab from Hash id
{
showSection( window.location.hash); // To get the div id
}
else // If no hash found then default first tab is opened
{
$('ul#verticalNav li:first-child a').click();
}
}
});
HTML source code
<ul>
<li><a href="#a">a</a></li>
<li><a href="#b">b</a></li>
</ul>
<div id="sections">
<div class="section" id="a">
</div>
<div class="section" id="b">
</div>