Help me please. How to change active tab by default in responsive website versions?
In the desktop version, by default, I should display the first tab, and in the mobile version, the second tab.
Help me please. How to change active tab by default in responsive website versions?
In the desktop version, by default, I should display the first tab, and in the mobile version, the second tab.
Hi Ksenia, you’d do that with script.
Probably ID your second tab, e.g. mobile-tab
.
Set the first tab as the default and do nothing on desktop view. Then on page load, look for mobile-width and if the page is < X, click tab 2.
In /body custom code that would look something like;
<script>
$(function() {
if ($(window).width() <= 767)
$("#mobile-tab").click();
});
</script>
767 is mobile landscape breakpoint, use 478 for mobile portrait.
Thank you very much for the help!