title: Auto scroll to span element
body: <p>I have an  element that contains (surprise!) an article.</p>
  
  <p>There is a list of tags at the top of the page that are found in the article.
  When a user clicks a tag it any matching words in the article are highlighted.</p>
  
  <p>What I am having trouble with is then automatically scrolling to the highlighted word.</p>
  
  <p>Is there any way to do this with javascript/jQuery?</p>
  
  <p>The following is my code to find the word and highlight it:</p>
  
  <pre><code>$(".article-tags a.toggle").live("click", function () {
          var $this = $(this);
          var $p = $this.closest("p");
          if ($p.find("span.highlight").length == 0) {
              $("#viewer .article-body").highlight($this.text());
              $this.highlight($this.text());
              document.getElementById("viewer").scrollTop = $p.find("span.highlight").offsetTop;
          }
          else {
              $("#viewer .article-body").removeHighlight();
              $p.removeHighlight();
          }
          return false;
      });
  </code></pre>
  
  <p>Thanks.</p>