title: javascript remove div onclick
body: <p>with pure javascript, I need to remove a <code>li</code> on click the <code>span</code>.</p>
  
  <ul>
  <li>By clicking <code>remove</code> I want to remove its div.</li>
  </ul>
  
  <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>Object.prototype.remove = function(){
      this.parentNode.removeChild(this);
  };
  
  var lis = document.querySelectorAll('li');
  var button = document.querySelectorAll('span');
  
  for (var i = 0, len = lis.length; i &lt; len; i++) {
      button[i].addEventListener('click', remove, false);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul&gt;
      &lt;li&gt;List item one&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;List item two&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;List item three&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;List item four&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;List item five&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;List item six&lt;span&gt; remove&lt;/span&gt;&lt;/li&gt;
  &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>