title: Javascript auto scroll on div
body: <p>I would like to scroll at the end of the div so in my case I can see the last message of chat.
  Here's what I have but it doesn't work, the scroll is actually on top of the div.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var divChat = document.getElementById('chat');
  divChat.scrollTop = divChat.scrollHeight;
  &lt;/script&gt;
  &lt;div id="chat" style="border-style:groove;overflow-y: auto; height:50%;"&gt;
  &lt;?php 
      $response = $bdd-&gt;query('SELECT * FROM minichat');
      while ($rsp = $response-&gt;fetch())
      {
          echo '['.$rsp['date_message'].']'." &lt;strong&gt;".htmlspecialchars($rsp['pseudo'])
          ."&lt;/strong&gt;: ".htmlspecialchars($rsp['message'])."&lt;br&gt;";
      }
  ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks by advance for any help,</p>