S
S
Sergey2020-05-10 09:36:41
JavaScript
Sergey, 2020-05-10 09:36:41

Navigate to anchor without clicking and changing url?

Hello, how can I implement this without updating the url?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2020-05-10
@deepprod

Window.scrollTo()

E
Emran Begov, 2020-05-10
@Emran

Scroll to the desired element on the page

const el = document.querySelector('#el'); // элемент до которого нужно скролить страницу
    el.scrollIntoView({
      block: 'start', // если start то страница будет прокручена к началу элемента 
      behavior: 'smooth' // отвечает за плавную прокрутку
      });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question