我有一個Tab Tab,它有很長的內容,所以用戶有下一個和上一個按鈕會更好。Bootstrap Tabpanel Next Previous按鈕
但他們不工作。
這是ASPX代碼:
<div class="col_4">
<div class="bs-example bs-example-tabs" role="tabpanel" data-example-id="togglable-tabs">
<ul id="myTab" class="nav nav-tabs nav-tabs1" role="tablist">
<li role="presentation" class="active"><a href="#aboutmyself" id="aboutmyself-tab" role="tab" data-toggle="tab" aria-controls="aboutmyself" aria-expanded="true">About Myself</a></li>
<li role="presentation"><a href="#familydetails" role="tab" id="familydetails-tab" data-toggle="tab" aria-controls="familydetails">Family Details</a></li>
<li role="presentation"><a href="#partnerpreference" role="tab" id="partnerpreference-tab" data-toggle="tab" aria-controls="partnerpreference">Partner Preference</a></li>
<li role="presentation"><a href="#contact" role="tab" id="contact-tab" data-toggle="tab" aria-controls="contact">Contact</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="aboutmyself" aria-labelledby="aboutmyself-tab">
<!--Tab1 content-->
<a class="btn-all btnNext" >Next</a>
</div>
<div role="tabpanel" class="tab-pane fade" id="familydetails" aria-labelledby="familydetails-tab">
<!--Tab2 content-->
<a class="btn-all btnPrevious" >Previous</a>
<a class="btn-all btnNext" >Next</a>
</div>
<div role="tabpanel" class="tab-pane fade" id="partnerpreference" aria-labelledby="partnerpreference-tab">
<!--Tab3 content-->
<a class="btn-all btnPrevious" >Previous</a>
<a class="btn-all btnNext" >Next</a>
</div>
<div role="tabpanel" class="tab-pane fade" id="contact" aria-labelledby="contact-tab">
<!--Tab4 content-->
<a class="btn-all btnPrevious" >Previous</a>
</div>
這裏是腳本。
<script type="text/javascript">
$('.btnNext').click(function() {
$('.nav-tabs > .active').next('li').find('a').trigger('click');
});
$('.btnPrevious').click(function() {
$('.nav-tabs > .active').prev('li').find('a').trigger('click');
});
</script>
使用bootstrap的'tab'功能,它會更好 http://getbootstrap.com/javascript/#tabs –
不錯的建議,但我不能改變設計,因爲我和我的朋友都在一個組中,他做了這樣的設計:P –