When clicking on a link instead of a smooth scroll, the console gives an error

TypeError: $ (...). Offset (...) is undefined

$(".nav-items li a").click(function() { var elementClick = $(this).attr("href"); var destination = $(elementClick).offset().top; $('html, body').animate({ scrollTop: destination }, 600); return false; }); 
 <div class="nav-items"> <li class="is-active nav-elem"><a href="#header">01<p>Главная</p></a></li> <li class="nav-elem"><a href="#about">02<p>О нас</p></a></li> <li class="nav-elem"><a href="#portfolio">03<p>Портфолио</p></a></li> <li class="nav-elem"><a href="#services">04<p>Услуги</p></a></li> <li class="nav-elem"><a href="#contact">05<p>Связаться</p></a></li> </div> 

  • because the item with the selected id is not on the page. - Grundy

0