title: Conflicting Jquery - ScrollTop()
body: <p>I am having trouble getting these two snippets to work. The first block works when the second block is not present. The second block works regardless.</p>
  
  <p>Block one is to smooth scroll any links linked to anchors in the page.
  Block two is for a sticky nav I have.</p>
  
  <p>I am guessing there is an issue as they both use scrollTop().</p>
  
  <p>So at the moment with both of these blocks of code in the page the smooth scroll only works on on anchors lower down the page, and not up (E.g. Top the top Button). So it effectively only works on downwards scroll links and not upward...</p>
  
  <pre><code>$(document).ready(function() {
  
      $('a[href^="#"]').on('click', function(event) {
          var target = $($(this).attr('href'));
          if( target.length ) {
              event.preventDefault();
              $('html, body').animate({
                  scrollTop: target.offset().top
              }, 1000);
          }
      });
  
  
      var stickyNavTop = $('#head-nav-cont').offset().top;
      var stickyNav = function(){
      var scrollTop1 = $(window).scrollTop();
  
          if (scrollTop1 &gt; stickyNavTop) { 
              $('#head-nav-cont').addClass('sticky');
              //$('#home-slideshow').addClass('stickied');
          } else {
              $('#head-nav-cont').removeClass('sticky'); 
              //$('#home-slideshow').removeClass('stickied'); 
          }
      };
  
      stickyNav();
  
      $(window).scroll(function() {
          stickyNav();
      });
  
  });
  </code></pre>