title: Scroll to top of div within a div jquery
body: <p>I have a div containing several other divs, I want to be able to have which ever div is clicked to scroll to the top of the containing div.</p>
  
  <p>I don't want to simply scroll to the top of the div, which would be scrollTop:0, I want whichever div is clicked for that div to scroll to the top. </p>
  
  <p>Using scrollTop: $(this).offset().top only gives the offset relative to the container, so it's not correct, as it only returns a relatively small value.</p>
  
  <p>Here's the setup:</p>
  
  <pre><code>    &lt;div id="container" style="position:relative; height:400px; width:100%; overflow:auto;"&gt; 
  &lt;div id="div1" class="clicker" style="height: 1000px; width 100px; ; background:blue"&gt;
          Test
      &lt;/div&gt;
  
      &lt;div id="div2" class="clicker" style="height: 1000px; width 100px; background:green"&gt;
          Test 2
      &lt;/div&gt;
  
       &lt;div id="div3" class="clicker" style="height: 1000px; width 100px; background:yellow"&gt;
          Test 3
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>with this JS:</p>
  
  <pre><code>$(".clicker").click(function ()
                      {
                      $('#container').animate({
                          scrollTop: WHAT GOES HERE?
                      }, 2000);
  
              });
  </code></pre>
  
  <p>Here's the jsfiddle:</p>
  
  <p><a href="http://jsfiddle.net/byvL43u6/" rel="nofollow">http://jsfiddle.net/byvL43u6/</a></p>
  
  <p>cheers</p>