Add a zero-block, fill it with content, and create several buttons with the class: .tab_btn
Add 2 arrow icons with the classes `left_tab` and `right_tab` (if you want to switch using the arrows).
Make copies of the Zero-block and edit the content.
Insert the code into the page in the block "Other - T123".
Insert the IDs of all your blocks into the code on the page in "T123" as follows: `['#rec346064270', '#rec346073573']`.
<!-- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π±Π»ΠΎΠΊ Ρ ΡΠ°Π±Π°ΠΌΠΈ. ΠΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ
zero-block ΡΠ΅ΡΠ΅Π· ΠΊΠ½ΠΎΠΏΠΊΠΈ -->
<!-- https://youx.agency/sozdaem-blok-s-tabami-pereklyuchenie-neskolkih-zero-block-cherez-knopki -->
<style>
.t-rec.posAnsld{
position : absolute;
width:100%;
top:0;
}
.outVis{opacity:0}
.outInd{z-index:-1}
.maintabsection , .outInd { position: relative}
.maintabsection { overflow: hidden}
.tab_btn , .right_tab, .left_tab {
cursor:pointer;
outline: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.stoptab{pointer-events:none}
.timestep{ transition:all 300ms ease-in-out}
</style>
<script>
$( document ).ready(function() {
let timestep = 300;
//ID Zero
var sbZero = [
['#rec896331276','#rec943331277','#rec44431278']
];
//Π‘ΠΎΠ·Π΄Π°ΡΠΌ ΠΎΠ±ΡΡΡ ΡΠ΅ΠΊΡΠΈΡ Π΄Π»Ρ Π±Π»ΠΎΠΊΠΎΠ²
$.each(sbZero, function(index) {
let groupID='';
$.each(sbZero[index], function(key) {groupID += sbZero[index][key]+',' });
$(groupID.slice(0, -1)).wrapAll('<div class="maintabsection"></div>');
});
//ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΊΠ»Π°ΡΡΡ ΠΊ Π½Π°ΡΠΈΠΌ Zero
$('.maintabsection').each(function() {
$(this).find('.t-rec:not(:first)').addClass('outVis outInd posAnsld');
});
function changeTab(em,el){
em.height( em.find('.t-rec:eq('+el+')').height() );
em.find('.t-rec:eq('+el+')').removeClass('outVis');
em.find('.t-rec:eq('+el+') .tab_btn:eq('+el+')').addClass('actbtnZ');
em.find('.t-rec').not(':eq('+el+')').addClass('outVis timestep');
$('.tab_btn, .right_tab , .left_tab').addClass('stoptab').css('cursor','default');
setTimeout(function(){
em.find('.t-rec:eq('+el+')').removeClass('outInd');
em.find('.t-rec').not(':eq('+el+')').addClass('outInd').removeClass('timestep');
$('.tab_btn, .right_tab , .left_tab').removeClass('stoptab').css('cursor','pointer');
}, timestep);
};
//ΠΡΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ
$('.tab_btn').click(function(){
let mSect = $(this).closest('.maintabsection');
let posBtn = $(this).closest('.t-rec').find('.tab_btn').index(this);
mSect.find('.tab_btn').removeClass('actbtnZ');
changeTab(mSect,posBtn);
});
//ΠΡΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ Π²ΠΏΡΠ°Π²ΠΎ
$('.right_tab').click(function(){
let mSect = $(this).closest('.maintabsection');mSect.addClass('acive_tab');
let summBlk = mSect.find('.t-rec').length-1;
let posArrow = $(this).closest('.t-rec').index('.acive_tab .t-rec');
mSect.removeClass('acive_tab');
if(posArrow<summBlk){changeTab(mSect, posArrow+1)
}else{ changeTab(mSect, 0)};
});
//ΠΡΠΈ ΠΊΠ»ΠΈΠΊΠ΅ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ Π²Π»Π΅Π²ΠΎ
$('.left_tab').click(function(){
let mSect = $(this).closest('.maintabsection');mSect.addClass('acive_tab');
let summBlk = mSect.find('.t-rec').length-1;
let posArrow = $(this).closest('.t-rec').index('.acive_tab .t-rec');
mSect.removeClass('acive_tab');
if(posArrow>0){changeTab(mSect, posArrow-1)
}else{ changeTab(mSect, summBlk)};
});
$(window).resize(function() {clearTimeout(window.resizedFinished); window.resizedFinished = setTimeout(function(){ $('.actbtnZ').click()}, 2000);});
});
</script>