简体   繁体   中英

jQuery scroll top function is not working

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) });

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); 
});

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); 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM