title: JavaScript: How to Hide / Unhide <div>
body: <p>I'm trying to avoid using <code>innerHTML</code> because it causes my browser to crash, probably due to the 250 milliseconds refresh rate.</p>
  
  <p>Anyway, I would rather have some content in an hidden <code>&lt;div&gt;</code> and make the <code>&lt;div&gt;</code> visible only if a certain condition is met. What's the best approach to go around this?</p>
  
  <p>Basically, what I'm doing now is..</p>
  
  <pre><code>setInterval(function () {
      if (serverReachable()) {
          .... // lines of code
          .... // lines of code
      var changeIt = document.getElementById('change')
      changeIt.innerHTML = '';
             timeout = setInterval(function(){window.location.href = "Tracker.html";},5000);
          }
      } else {
          clearTimeout(timeout);
          timeout = null;
      var changeIt = document.getElementById('change')
      changeIt.innerHTML = 'offline';
     }
  }, 250);
  </code></pre>
  
  <p>This will crash my browser, because I'm not using <code>innerHTML</code> to print "offline" but a whole <code>&lt;div&gt;</code>. I want to have this <code>&lt;div&gt;</code> hidden, and instead of using <code>innetHTML</code>, to simply unhide if a condition is met (in this case, no internet connection).</p>