我有两个同步工作的标签式导航。 但每当我点击底部标签时,窗口就会跳跃 到顶部。我不知道他们是否使用相同的班级名称。
任何帮助将不胜感激, 麦克
HTML:
<!-- TOP TAB -->
<section id="registerTabsContainer">
<ul class="tabs">
<li><a href=".tabViewer">Are you a Viewer?</a></li>
<li><a href=".tabBusiness">Are you a Business?</a></li>
<li><a href=".tabPlatform">Are you a Platform?</a></li>
</ul>
<!-- TOP CONTENT -->
<div class="registerTabsContent tabViewer">
<h1>Register as a Viewer</h1>
</div>
<div class="registerTabsContent tabBusiness">
<h1>Register as a Business</h1>
</div>
<div class="registerTabsContent tabPlatform">
<h1>Register as a Business</h1>
</div>
<!-- BOTTOM TAB -->
<section id="tourSummaryTabsContainer">
<ul class="tabs">
<li><a href=".tabViewer">Are you a Viewer?</a></li>
<li><a href=".tabBusiness">Are you a Business?</a></li>
<li><a href=".tabPlatform">Are you a Platform?</a></li>
</ul>
<!-- BOTTOM CONTENT -->
<div class="tourSummaryTabsContent tabViewer">
<h1> Viewer content Bottom</h1>
</div>
<div class="tourSummaryTabsContent tabBusiness">
<h1>Register as a Business</h1>
</div>
<div class="tourSummaryTabsContent tabPlatform">
<h1>Register as a Business</h1>
</div>
jQuery的:
$(document).ready(function () {
// tabs script
$('li:eq(0) a', '.tabs').addClass('active');
$('.registerTabsContent:not(:first), .tourSummaryTabsContent:not(:first)').hide();
$('.tabs li a').click(function(e) {
e.preventDefault();
if (!$(this).hasClass('active')) {
$('a.active').removeClass('active');
var i = $(this).parent().index();
$('li:eq(' + i + ') a', '.tabs').addClass('active');
$('.registerTabsContent, .tourSummaryTabsContent').hide();
var t = $(this).attr('href');
$(t).fadeIn('slow');
return false;
}
});
});