Tabs scroll down on click only works first click

Hi, I added a custom JavaScript for tabs scroll down on click. It only works for the first click, the second click will go back to default scroll to top. Please help.

https://channelnetwork.org/tool/

Thank you.

Hello Philip,

Thanks for writing in!

We have checked your site and we have seen your custom JS code. You added this:

/* tab scroll on click */
jQuery(function($) {
  $('.x-tabs-list button').click(function(event) { 
  event.preventDefault();
  if (window.matchMedia("(min-width: 983px)").matches) { /* scroll up to top*/ 
      $('html, body').animate({scrollTop: $('.masthead').offset().top}, 'fast');
  }
  else { /* scroll down to top of content*/ 
      $('html, body').animate({scrollTop: $('.x-tabs-panel').offset().top - $('.x-navbar').outerHeight() - 46}, 'fast');
  }
  });
});

It is not throwing any JS error or anything. It should have worked like it was intended to do. Regretfully, custom coding is beyond the scope of our support. our support only covers getting your site setup, bug fixes, and minor cosmetic changes. You may need to contact a 3rd party developer to do these customizations for you.

Note: We are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.