davesmiths
3/3/2014 - 2:18 PM

Scroll to top on clicking a sticky nav snippet

Scroll to top on clicking a sticky nav snippet

$('.stickynavbar').on('click', function(e) {
    if ($(e.target).closest('a,input,textarea').length === 0) {
      //window.scrollTo(0, 0);
      $('html, body').animate({ scrollTop: 0 }, 150, 'linear');
    }
});
// Thanks http://stackoverflow.com/questions/1144805/how-do-i-scroll-to-the-top-of-the-page-with-jquery