title: Scroll to element inside modal window
body: <p>I have a modal window and need to be able to open the modal and then scroll the user to a specific spot in the modal.<br>
  I am getting the modal contents with AJAX to a PHP script. </p>
  
  <p>eg mypage.php?loc=someid </p>
  
  <p>In the PHP script I have this JS to do the scrolling:</p>
  
  <pre><code>$( document ).ready(function() {
   $('.modal-body').animate({
      scrollTop: $("#&lt;?php echo $_GET['loc'];?&gt;").offset().top
   }, 1000);
  });
  </code></pre>
  
  <p>in the PHP page is some HTML like this:</p>
  
  <pre><code>&lt;div id="someid"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>My content loads correctly but the amount of scroll that happens appears to be relative to the link that opened the modal so it does not actually find the div in the doc.<br>
  I am guessing my JS needs a little tweaking.</p>
  
  <p>It seems I need to be able to calculate the offset of the element from the top of the modal content.</p>
  
  <p>I can fake this by setting the value against the element I am scrolling to like this. But I really need a programmatic way of calculating this. Obviously different devices will not work correctly as shown.</p>
  
  <pre><code>$( document ).ready(function() {
   $('.modal-body').animate({
      scrollTop: $("#&lt;?php echo $_GET['loc'];?&gt;").attr('distance')
   }, 1000);
  });
  //Trying to find out how far this div is from the top of the modal window?
  &lt;div id="someid" distance="670"&gt;&lt;/div&gt;
  </code></pre>