sameeuor
sameeuor

Reputation: 684

Jquery scroll to top offset is not working

$(document).ready(function() {
    $("a.slider-down").click(function(e) {
    $('html, body').animate({
        scrollTop: $("#about-full").offset(70).top
    }, 1500);
});
}); 

How to set offset value to this script? This code is wrote for scroll to top when click link. offset(70) not working

Upvotes: 0

Views: 717

Answers (2)

sameeuor
sameeuor

Reputation: 684

Change the line where you assign to scrollTop as follows:

scrollTop: $("#about-full").offset().top - 70

This is working.

Upvotes: 0

Rohan Kumar
Rohan Kumar

Reputation: 40639

Don't pass any value in offset() function it take object having top and left keys, change the below code

scrollTop: $("#about-full").offset(70).top

to

scrollTop: $("#about-full").offset().top

And if you want to set top only for 70 then use,

scrollTop: 70

Upvotes: 1

Related Questions