title: JS if statement - innerHTML
body: <pre><code>function colorize(){
      for(i = 1; i&lt;=8; i++)
      {
          var id = document.getElementById('op' + i);
  
          var stat = id.innerHTML;
          document.write(stat + " ");
          if(stat == 1)
          {
              id.innerHTML = "&lt;div style='background:#00FF00; width: 20px; height: 20px; border-radius: 15px;'&gt;&lt;/div&gt;";
          }
          else{
              id.innerHTML = "&lt;div style='background:#FF0000; width: 20px; height: 20px; border-radius: 15px;'&gt;&lt;/div&gt;";
          }
      }
  }
  </code></pre>
  
  <p>It should check if there is a 1 or 0 and replace it with a green or red circle, but I only get red circles. </p>
  
  <p>"stat" printing gave me an " 0 0 0 1 1 1 1 1"  but it seem to be not working with the if statement. Does anybody know why?</p>