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() {
$(this).click(function() {
showSection( $(this).attr('href') );
});
});
$('ul#verticalNav li:first-child a').click();
}
});
<ul id="verticalNav">
<li><a href="#section1">Section I</a></li>
<li><a href="#section2">Section II</a></li>
<li><a href="#section3">Section III</a></li>
</ul>
<div id="sections">
<div class="section" id="section1">
<p>Some content specific to this section...</p>
</div>
<div class="section" id="section2">
<img src="#" alt="BADGER" />
</div>
<div class="section" id="section3">
<img src="#g" alt="SNAKE" />
</div>
</div>
我必须为每个选项卡示例 index.html#section1 , index.html#section2 创建特定链接