How to change Webflow tab programmatically?

I have a list of links identical to the list of the tabs. When I press one of that link, I want the corresponding tab to be shown.


Ответы (1 шт):

Автор решения: Alex Freshmann

Add a param "id" to the links. Now add an "id" with the format "{link_id}_tab" to each tab. Now you can add this js script:

$('.footer_link').on('click', function (evt) {
  evt.preventDefault();
  var id = $(this).attr('id') + '_tab';
  $('.w-tab-link').attr('aria-selected', false);
  $('.w-tab-link').removeClass('w--current');
  $(`#${id}`).attr('aria-selected', true);
  $(`#${id}`).addClass('w--current');
  $('.w-tab-pane').removeClass('w--tab-active');
  $(`.w-tab-pane[aria-labelledby="${id}"`).addClass('w--tab-active');
});
→ Ссылка