Home > OS >  jQuery scroll top function is not working
jQuery scroll top function is not working

Time:11-08

So here is my code and I have this error and I don't understand why. I need some help here... I don't know why is this happening : Property does not exist on type '.js--section-plan'.ts(2339) when i hover on the offset() in vscode

$('.js--scroll-to-plans').click(function() 
  { $('html, body).animate({scrollTop:. 
    ('.js--section- 
    plan').offset().top},1000) });

CodePudding user response:

You should put a quote mark on the end of the body, just right before the paranthesis. Also that period isn't needed after the colon.

$('.js--scroll-to-plans').click(function() { 
  $('html, body').animate({
    scrollTop: ('.js--section- plan').offset().top
  }, 1000); 
});

CodePudding user response:

There are some minor typos in your script. Do not forget to use $-sign.

$('.js--scroll-to-plans').click(function() { 
    $('html, body').animate({
   scrollTop: $('.js--section-plan').offset().top
 }, 1000); 
});
  • Related