title: JavaScript error while assigning a value to script tag src attribute
body: <p>I am trying to add a word in my between by src using JavaScript, by getting that word from another div element. Running it results in the following error:  </p>
  
  <blockquote>
    <p>Cannot set property 'src' of null`
    Here's my code:</p>
  </blockquote>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;
  &lt;div id='content'&gt;&lt;/div&gt;
  &lt;script&gt;
  function handleResponse(response) {
    var post_number  = Object.keys(response.items).length; //number of posts
    for (i=0; i&lt;post_number; i++) { 
      document.getElementById("content").innerHTML += "&lt;div class='posts'&gt;&lt;h1&gt;" + response.items[i].title + "&lt;/h1&gt;" + response.items[i].content + '&lt;/div&gt;';
        
    }
  }
  &lt;/script&gt;
  &lt;div id='myImg'&gt;Lists&lt;/div&gt;
  &lt;script id='demo' src=""&gt;&lt;/script&gt;
  &lt;script&gt;
  var x = document.getElementById("myImg").innerHTML;
  var y= document.getElementById("demo"); y.src="https://www.googleapis.com/blogger/v3/blogs/5039479718685240371/posts?labels="+x+"&amp;callback=handleResponse&amp;key=AIzaSyDxfWmXTRnO5yIp25NvuUEBWKSa_5mqjHA";
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>