Not working jQuery code, what's the matter?

Don't understand what the problem is: I inserted the code for the smooth scroll to anchors not working. I tried to change the settings of the connected slider is also not displayed on the website. Maybe someone will look, I think the error is trivial.

here the code
here page
April 19th 20 at 12:23
2 answers
April 19th 20 at 12:25
The bug is really trivial. Your js is looking for a section with an id of hash references, but there are sections you have not, there are classes rather than id
April 19th 20 at 12:27
Can use this code for smooth scrolling to anchors:

document.querySelectorAll('a[href^="#"]').forEach((elem) => {
 elem.addEventListener("click", (e) => {
 let block = document.querySelector(elem.getAttribute("href")),
 offset = elem.dataset.offset
 ? parseInt(elem.dataset.offset)
 : 0,
 bodyOffset = document.body.getBoundingClientRect().top;
 top: block.getBoundingClientRect().top - bodyOffset + offset,
 behavior: "smooth"

Support browsers:

In the script there is also an additional feature which allows you to specify the indent for the section.

It is enough to specify for example:

<a href="#section-2" data-offset="200">Section 2</a>

And for the second section of the lower indent.

The sandbox:

Or use:

html {
 scroll-behavior: smooth;

Support browsers:
thanks for the reply, but I want to understand what the point is in this situation - why does not jquery, so in the future had a problem with it - Madie commented on April 19th 20 at 12:30
Please note that for Safari the smooth scroll will not (often very critical)
But there was polyfil - aurelie.Schimmel commented on April 19th 20 at 12:33

Find more questions by tags jQuery