Uncaught error trying to use smooth scroll


I’ve added the suggested code to the page to allow elements to scroll to specific areas of the page, and I’ve set up the buttons with the correct #anchor elements. This is the code I used:

  lp.jQuery(function($) {
// The speed of the scroll in milliseconds
var speed = 1000;
// Find links that are #anchors and scroll to them
  .not('.lp-pom-form .lp-pom-button')
  .bind('click.smoothScroll', function(event) {
    $('html, body').animate({ scrollTop: $( $(this).attr('href') ).offset().top }, speed);

However when I click the buttons nothing happens and there is an error in the console that says
Uncaught TypeError: Cannot read property ‘top’ of null


Hi @irvineinteractive,

Are you loading the right jQuery library before the smooth scroll script?

It would be helpful if you share the actual landing page URL so we can take a look.



I am not explicitly loading any jquery libraries but the Unbounce page has them on there.

Do I need to load the jquery.smooth-scroll.js on my page?