title: jQuery Smooth Scroll to any Anchor
body: <p>I have tried many different codes to smooth scroll to anchors. I can't find one that works. It needs to be able to scroll vertically, horizontally, and diagonally. Another problem I find with others is that they don't seem to work with multiple targets. I want it to be able to scroll to any anchor on the page without having to edit the script.</p>
  
  <p><strong><a href="http://jsfiddle.net/b2550/B3F25/4/" rel="noreferrer">Fiddle</a></strong></p>
  
  <p><strong>This is the code that matches this the closest, I cant get it to work:</strong></p>
  
  <pre><code>var $root = $('html, body');
  $('a').click(function () {
  
      $root.animate({
  
          scrollLeft: $($.attr(this, 'href')).offset().left,
          scrollTop: $($.attr(this, 'href')).offset().top
  
      }, 500);
  
      return false;
  });
  </code></pre>
  
  <p>It works in JSFiddle but when I put it on my page it doesn't work.</p>
  
  <p><strong>Why is this not a duplicate?</strong>
  This is a multi-direction script that doesn't target single elements. It applies to all the links on the page.</p>