Code

Scroll to Top of Page on Tab Click

Automatically scroll a user to the top of page on a tab change on your Webflow site. A simple Javascript code snippet that allows for you to scroll users to the top of your site based on your selected class.

Scroll to Top of Page on Tab Click preview

Automatically scroll a user to the top of page on a tab change on your Webflow site. A simple Javascript code snippet that allows for you to scroll users to the top of your site based on your selected class.

How to add it

  1. Add Javascript code snippet to closing body custom code
  2. Update class name to the element you want users to scroll to top on click

The code

Javascript
                      <!-- Add to body close section -->
<script>

$(".your-tab-class").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});

</script>

                    

Browse similar code snippets

Language

More from Timothy Ricks

Profile →

Related Webflow questions

All answers →

Similar code snippets

All code snippets →