title: Vanilla Javascript function working on JsFiddle but not on site?
body: <p>I have a weird problem, I've written a function that works fine on jsFiddle but when i write it in my HTML nothing happens...</p>
  
  <pre><code>var el = document.querySelectorAll(".sp-methods li:first-child");
  for (i = 0; i &lt; el.length; i++) {
     alert('sad')
     el[i].style.display='none';
  }
  </code></pre>
  
  <p>My Full HTML is</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;script&gt;
  /*if(!window.location.href.indexOf("gpf") &gt; 0){
      alert('contains gpf, show 4-6 days');
  } else {*/
      var el = document.querySelectorAll(".sp-methods li:first-child");
      for (i = 0; i &lt; el.length; i++) {
         alert('sad')
         el[i].style.display='none';
      }
  /*}*/
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;ul class="sp-methods"&gt;
    &lt;li class="  "&gt;Hide me&lt;/li&gt;
    &lt;li class="  "&gt;Dont hide me&lt;/li&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Yet it works here and I have no idea why?</p>
  
  <p><a href="https://jsfiddle.net/td8apuuj/1/" rel="nofollow">JSFiddle Link</a></p>