HTML:<div class="tab_block">
<div class="tab">Content#1</div>
<div class="tab">Content#2</div>
<div class="tab">Content#3</div>
</div>
<div class="nav_block">
<a href="#" class="prev">prev</a>
<a href="#" class="next">next</a>
</div>
CSS:.d-none{
display: none;
}
.tab{
display: none;
}
.tab.selected{
display: block;
}
JavaScript:$(document).ready(function(){
$('.tab:first').addClass('selected');
$('.nav_block a').click(function(e){
e.preventDefault();
let this_selected_tab = $('.tab.selected');
if($(this).hasClass('prev')){
if(this_selected_tab.prev('.tab').length > 0){
this_selected_tab.prev('.tab').addClass('selected');
}else{
$('.tab:last').addClass('selected');
}
}
if($(this).hasClass('next')){
if(this_selected_tab.next('.tab').length > 0){
this_selected_tab.next('.tab').addClass('selected');
}else{
$('.tab:first').addClass('selected');
}
}
this_selected_tab.removeClass('selected');
});
});