White Arrow icon
Back to all Elements

Auto change tabs

A script to automatically switch between tabs in a loop.

As before, this element need 2 steps:

1. Add the next script tot the relevant page, where your tabs are.

<script>

 var Webflow = Webflow || [];

 Webflow.push(function() {

   var tabTimeout;

   clearTimeout(tabTimeout);

   tabLoop();

   function tabLoop() {

     tabTimeout = setTimeout(function() {

       var $next = $('.tabs-menu').children('.w--current:first').next();

       if ($next.length) {

         $next.click();

       } else {

         $('.tab-link:first').click();

       }

     }, 3000);

   }

   $('.tab-link').click(function() {

     clearTimeout(tabTimeout);

     tabLoop();

   });

 });

</script>

Copy

2. Adjust classnames to match. You can change the classnames in the script or the classnames of the elements in your page:

  • 'tabs-menu' is the classname of the wrapping menu links element (the one that says 'Tabs Menu').
  • 'tab-link' is the classname of the actual links to the tabs.

* You can change the timing between each tab, now set to 3000ms (3 sec.) by changing the number 3000 to any other milliseconds number.

** The last part of this script is a function that resets the "timer" when a 'tab-link' is clicked.

Preview:

browser mockup
Share:
Heart icon

When your bath soap bar gets too small to use, don't throw it away! open the next bar, and when you finish showering, stick the small old bar to the back of the new bar. Onces they both dry, they will become one.

Might also interest you:

Symbol in RichText

Cloneable
CMS
Code

Insert a symbol element into a RichText. On a static or dynamic page.

Read more
Blue arrow iconWhite Arrow icon

Pass Parameters

Cloneable
Code

Pass input fields parameters and add them to the destination URL.

Read more
Blue arrow iconWhite Arrow icon

Before / After effect

Cloneable
Tricks
Interactions

A Before / After effect for photos, without any code. Only Webflow's interaction.

Read more
Blue arrow iconWhite Arrow icon