title: Cannot read property 'scrollHeight' of null
body: <p>The error message I am getting is <code>Cannot read property 'scrollHeight' of null</code>:    </p>
  
  <pre><code>var b = document.getElementById('chat-messages');
  b.scrollTop = b.scrollHeight;
  
  var lst = b.scrollTop;
  console.log(lst);
  
  b.addEventListener("scroll", function() {
    if (b.scrollTop &gt; lst) {
      console.log("Greater than Last");
    } else {
      console.log("Less or equal than last.");
    }
  
    lst = b.scrollTop;
  });
  </code></pre>
  
  <p>Please help me. Thanks!</p>