Published
July 8, 2023
Let's say you want to be able to change the selected tab based on;
- Something else happening on the page, such as the user clicking on a button.
- Specific indications in the URL such as ?tab=mango .
Technical
There are at least two ways to change Webflow's tabs.
Either can be triggered by page-load checking the querystring
Javascript Click Approach
Send a click() event to the tab, so that Webflow's javascript acts accordingly.
In this example you'd have a button with the ID my-button, and your tab would have the ID my-tab3.
<br>$("#my-button").click(function() {<br> $("#my-tab3").click();<br>}); <br> Javascript Class Change Approach
From Timothy Ricks;
<br>$(function() {<br> // Change the 3 to the number tab you want to be active<br> $(".your-tab-class").removeClass("w--current");<br> $(".your-tab-class:nth-child(3)").addClass("w--current"); <br>}); <br>
