當前「Previous」按鈕在第一個選項卡中不起作用,因爲它不在循環中。我應該如何設置它,以便當我的訪客點擊上一個時,它會顯示最後一個標籤?Next-Previous按鈕使用Bootstrap Tab循環工作
HTML:
<div>
<ul id="wheel-tab" class="nav nav-tabs nav-justified">
<li class="active"><a href="#ocean" data-toggle="tab">Ocean</a></li>
<li><a href="#air" data-toggle="tab">Air</a></li>
<li><a href="#customs" data-toggle="tab">Customs</a></li>
<li><a href="#transport" data-toggle="tab">Transport</a></li>
</ul>
<div class="tab-content">
<div id="ocean" class="tab-pane fade in active">
<h2>Ocean</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="air" class="tab-pane fade in active">
<h2>Air</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="customs" class="tab-pane fade in active">
<h2>Customs</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div id="transport" class="tab-pane fade in active">
<h2>Transport</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<a class="left carousel-control" href="#" id="wheel-left"role="button" data-slide="prev">
<span class="icon icon-left">Prev</span>
</a>
<a class="right carousel-control" href="#" id="wheel-right" role="button" data-slide="prev">
<span class="icon icon-right">Next</span>
</a>
</div>
JS:
var $tabs = $('#wheel-tab li');
$('#wheel-left').on('click', function() {
$tabs.filter('.active').prev('li').find('a[data-toggle="tab"]').tab('show');
});
$('#wheel-right').on('click', function() {
$tabs.filter('.active').next('li').find('a[data-toggle="tab"]').tab('show');
});
得到它的工作:) –
任何時候..編碼快樂.. :) –