Dnakk Phoenix
Dnakk Phoenix

Reputation: 1

jQuery page scroll with URL?

I'm new in this, so please don't kill me if it's obvious :) I have website created in bootstrap template and it has cool scrolling java script which works perfectly but when i click on link it doesn't change URL in browser. Is there please any chance to do that with this code ? Thank you :)

$(function() {
    id = id.replace("link", "");
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500, 'easeInOutExpo');
        event.preventDefault();
    });
});

Upvotes: 0

Views: 127

Answers (1)

Itay
Itay

Reputation: 51

this should do the job:

 $('a.page-scroll').click(function() {
    var $anchor = $(this);
    $('html, body').animate({
        scrollTop: $anchor.offset().top
    }, 1500);
});

Upvotes: 1

Related Questions