Y
Y
ysaeredir2015-10-05 08:10:31
JavaScript
ysaeredir, 2015-10-05 08:10:31

How to slow down the scrolling of the page on the site?

There is a navigation menu, each link has an identifier, which denotes a div at the bottom of the page. How do I make when I click on a link, the transition to the div block was not fast, but slow.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bears, 2015-10-05
@ysaeredir

It is possible like this:

<ul class="nav">
    <li><a href="#category-1">Категория 1</a></li>
    <li><a href="#category-2">Категория 2</a></li>
    <li><a href="#category-3">Категория 3</a></li>
</ul>

<div id="category-1">Описание категории 1</div>

$(function(){

    $('.nav a').on('click', function(e){
        e.preventDefault();
        $('html, body').animate({scrollTop: $($(this).attr('href')).offset().top}, 2000);
    });

});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question