Create auto switching tab with Elementor, custom css and js

Create auto switching tab with Elementor, custom css and js

Avro

2 года назад

22,107 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Sven Flätchen
Sven Flätchen - 26.10.2023 15:58

Just modified the script in some parts:

**** START OF THE modified script ****

jQuery(document).ready(function ($) {
let index = 0;
let delay = 5000;
let $tabs = $('.tab_wrap .tab');
let $contents = $('.content_wrap .box');
let interval = setInterval(rotate, delay);

$tabs.eq(0).addClass('active');

$tabs.each(function (i) {
$(this).click(function () {
index = i;
switchElement();
});
});

function rotate() {
index++;
if (index >= $tabs.length) {
index = 0;
}
switchElement();
}

function switchElement() {
clearInterval(interval);
$tabs.removeClass('active');
$contents.fadeOut(300);
$tabs.eq(index).addClass('active');
$contents.eq(index).delay(300).fadeIn(300);
interval = setInterval(rotate, delay);
}
});
**** END OF THE modified script ****

I made the following changes:
- Simplified the selection of the tabs and content elements, eliminating the unnecessary wrapping elements and using more concise selectors.
- Removed the redundant use of children when selecting the tabs and content elements.
- Simplified the way the "active" class is added and removed from tabs.
- Removed unnecessary repetition of selectors in the switchElement function.
- Reordered some statements for better readability.

Ответить
Bam Bam
Bam Bam - 14.08.2023 14:37

Very nice, thank you, but, it would be very helpful to add your code in the comment section so you don' t have to type everything in to experiment with it.
Thanks again

Ответить
Hasan Mahmud
Hasan Mahmud - 01.08.2023 10:05

Thank you so much man! it works just fine. But I am facing a problem like if you keep the tab open and come back after some time the animation looks so odd.

Ответить
Kavithran Shakthi
Kavithran Shakthi - 15.07.2023 07:42

This is not working for me

Ответить
Luka Boškin
Luka Boškin - 16.02.2023 13:52

Hi, good guide. But i cannot find "inner section" option in elemntor. Can you help?

Ответить
Nakul Kumar
Nakul Kumar - 21.12.2022 23:46

Really greate & amazing

Ответить
Sahil Khan
Sahil Khan - 08.12.2022 12:23

Really great tutorial and content.

Ответить
LG
LG - 05.10.2022 22:07

Hello, my screen flickers when switching the tab every time. Do you know how can I fix this? Great tutorial btw.

Ответить
samith fernando
samith fernando - 11.06.2022 22:43

Hi nice video its really helped and small thing without auto switching what will be the code?

Ответить
Mohammad Faizan
Mohammad Faizan - 20.03.2022 13:27

When I click to tab can I increase time to pause near 30 second
but switch timing is normal 5 second

Ответить
Bou Hama
Bou Hama - 29.01.2022 00:23

Great work Avro thanks
I tried but didn't work
can you add your code on the comments to test
many thanks

Ответить
Shubham Sharma
Shubham Sharma - 15.11.2021 09:51

where is the code

Ответить
HELPER
HELPER - 18.09.2021 21:50

Hi bro your content is amazing, but channel is underrated.... 😒

Ответить
Adie D
Adie D - 11.09.2021 17:38

How to change the background image or video for each elementor section for each
Tab, please? Thank you for the tutorial.

Ответить
Vizcults
Vizcults - 31.08.2021 21:49

thanks

Ответить
Sean Clarke
Sean Clarke - 31.08.2021 12:49

Thank you.

Ответить
Shashank Sachan
Shashank Sachan - 31.08.2021 06:26

Great work keep it up 👍

Ответить