Learn free online HTML5, javascript, and jquery Tutorials by Examples

Tuesday 31 January 2017

How to add offset to jquery scrolltop ?

$("nav#navigation li a[href^='#']").click(function(e) {
    e.preventDefault();
    var headerheihgt = $('#header').css('height');
     $('html, body').stop().animate({ 
 'scrollTop': $(this.hash).offset().top - parseInt(headerheihgt)
     }, 500);
});

No comments:

Post a Comment