title: How can i document.getElementbyID of a variable?
body: <p>I want to do a changing to certain <code>span</code> elements based in their <code>id</code>.</p>
  <p>So i give each one of <code>div</code> and <code>span</code> an <code>id</code>, and then i try to <code>.style.color</code> each of the <code>span</code>.</p>
  <p>but an error is to be seen : <code>Cannot read property 'style' of null&quot;</code></p>
  <p>I don't know what i am doing wrong.</p>
  <p>Here is a simple reproductible model of my program</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>for (y = 0; y &lt; 7; y++) {
    let colonne = document.createElement("div");
    colonne.className = "horaire_one";
    colonne.id = ("col" + y);
    for (x = 0; x &lt; 26; x++) {
      let span = document.createElement("span");
      span.className = "pasdispo_one_rpv";
      span.id = (colonne.id + x);
      document.getElementById(span).style.color = "green";
    }
  }</code></pre>
  </div>
  </div>
  </p>