javascript - jQuery scroll to ID script only scrolling down -


i'm using following make anchor class of .jump-link scroll id it's referencing in href attribute:

// scroll id $('.jump-link').click(function () {     var el = $(this).attr('href'),         elwrapped = $(el);     scrolltoid(elwrapped, 40);     return false; }); function scrolltoid(element, navheight) {     var offset = element.offset(),         offsettop = offset.top,         totalscroll = offsettop - navheight;     $('body,html').animate({         scrolltop: totalscroll     }, 500); } 

unfortunately though seems work scrolling down page. i'd script work scrolling page.

try this.. work.

$(".jump-link").click(function(){  var id = $(this).attr('href');         $('html, body').animate({scrolltop: $("#"+id).offset().top}, 2000); }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -