title: Sticky div on scroll with plain javascript
body: <p>I wrote this sticky div effect in Jquery but was wondering a way to do the same thing with vanilla javascript</p>
  
  <pre><code>.stick {
      position: fixed;
      top: 0;
  }
  
  
  
  $(document).ready(function () {  
    var top = $('#a8').offset().top;
    $(window).scroll(function (event) {
      var y = $(this).scrollTop();
      if (y &gt;= top)
        $('#a8').addClass('stick');
      else
        $('#a8').removeClass('stick');
  
    });
  });
  </code></pre>