我已經使用下一個和上一個按鈕功能創建了選項卡內容。但是下一個和上一個按鈕功能不起作用。我已經使用jquery.min.js版本1.11.1版本。我已經創建瞭如下的代碼片段。我已經提到this question並創建了答案中提到的功能。但仍然不起作用。下一個和上一個按鈕功能不起作用
$("ul.kyc-tab-list li a").click(function() {
$("ul.kyc-tab-list li a").removeClass("active");
$(this).addClass("active");
});
$(".tab-btn1").click(function() {
$("#tab1").show();
$("#tab2").hide();
$("#tab3").hide();
$("#tab4").hide();
$("#tab5").hide();
});
$(".tab-btn2").click(function() {
$("#tab1").hide();
$("#tab2").show();
$("#tab3").hide();
$("#tab4").hide();
$("#tab5").hide();
});
$(".tab-btn3").click(function() {
$("#tab1").hide();
$("#tab2").hide();
$("#tab3").show();
$("#tab4").hide();
$("#tab5").hide();
});
$(".tab-btn4").click(function() {
$("#tab1").hide();
$("#tab2").hide();
$("#tab3").hide();
$("#tab4").show();
$("#tab5").hide();
});
$(".tab-btn5").click(function() {
$("#tab1").hide();
$("#tab2").hide();
$("#tab3").hide();
$("#tab4").hide();
$("#tab5").show();
});
$('#btnNext').click(function() {
// get current tab
var currentTab = $(".tab.active");
// get the next tab, if there is one
var newTab = currentTab.next();
// at the end, so go to the first one
if (newTab.length === 0) {
newTab = $(".tab").first();
}
currentTab.removeClass('active');
// add active to new tab
newTab.addClass('active');
});
$('#btnPrevious').click(function() {
// get current tab
var currentTab = $(".tab.active");
// get the previous tab, if there is one
var newTab = currentTab.prev();
// at the start, so go to the last one
if (newTab.length === 0) {
newTab = $(".tab").last();
}
currentTab.removeClass('active');
// add active to new tab
newTab.addClass('active');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div>
<section>
<div class="kyc-tab-wrapper">
<ul class="kyc-tab-list">
<li>
<a href="javascript:void(0);" class="tab active tab-btn1"><span>01</span>Customer</a>
</li>
<li>
<a href="javascript:void(0);" class="tab tab-btn2"><span>02</span>Contact/Promotors</a>
</li>
<li>
<a href="javascript:void(0);" class="tab tab-btn3"><span>03</span>Bank/Business</a>
</li>
<li>
<a href="javascript:void(0);" class="tab tab-btn4"><span>04</span>Other</a>
</li>
<li>
<a href="javascript:void(0);" class="tab tab-btn5"><span>05</span>Finish</a>
</li>
</ul>
<div class="kyc-tab-content" id="tab1">
tab 1
</div>
<div class="kyc-tab-content" id="tab2">
tab 2
</div>
</div>
<div class="kyc-tab-content" id="tab3">
tab 3
</div>
<div class="kyc-tab-content" id="tab4">
tab 4
</div>
<div class="kyc-tab-content" id="tab5">
tab 5</div>
<div class="kyc-tab-form-btn-wrap">
<button id="btnPrevious" style="display:none"> Previous</button>
<button id="btnNext">Next </button>
</div>
</div>
</div>
</section>
</div>
您可以創建一個的jsfiddle爲了這? – adiga