title: How to check if two elements are intersecting in vanilla JavaScript?
body: <p>I have code like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    var $selection = $('.selection');
    $('li').filter(function() {
      var self = $(this);
      return /* ????? */;
    }).addClass('selected');
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.widget {
    width: 320px;
    height: 200px;
    border: 1px solid gray;
    position: absolute;
    overflow: scroll;
  }
  .selection {
    position: absolute;
    top: 90px;
    left: 90px;
    border: 1px dotted black;
    height: 120px;
    width: 120px;
  }
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  li {
    float: left;
    background: blue;
    width: 40px;
    height: 40px;
    margin: 10px;
  }
  li.selected {
    background: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="widget"&gt;
    &lt;div class="selection"&gt;&lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;li&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I select only those li elements that are intersecting with .selection rectangle?</p>