title: jQuery scrolling does not work with anchor
body: <p>I want to scroll the page to an anchor link. I'm using following code:</p>
  
  <pre><code>$('a').click(function(){
          $('html, body').animate({
              scrollTop: $( $(this).attr('href') ).offset().top
          }, 400);
          return false;
      });
  </code></pre>
  
  <p>It works fine if I have a url like this:</p>
  
  <pre><code>&lt;a href="#comments"&gt;Comments&lt;/a&gt;
  </code></pre>
  
  <p>However, the problem is that the url is automatically generated by adding the # at the end of current url, so it will be:</p>
  
  <pre><code>&lt;a href="http://example/sth/#comments"&gt;Comments&lt;/a&gt;
  </code></pre>
  
  <p>In this cause, it does not work. I cannot change the markup of the URL, how can I fix the jQuery to work with such url?</p>