title: How to add/remove a class in JavaScript?
body: <p>Since <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element.classList#Browser_compatibility" rel="noreferrer"><code>element.classList</code></a> is not supported in IE 9 and Safari-5, what's an alternative cross-browser solution?</p>
  
  <p><a href="http://vanilla-js.com/" rel="noreferrer">No-frameworks</a> please.</p>
  
  <p>Solution <strong>must</strong> work in at least <strong>IE 9</strong>, <strong>Safari 5</strong>, FireFox 4, Opera 11.5, and Chrome.</p>
  
  <p>Related posts (but does not contain solution):</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/2170878/how-to-add-and-remove-css-class">how to add and remove css class</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/5084182/add-and-remove-a-class-with-animation">Add and remove a class with animation</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/3066692/add-remove-class">Add remove class?</a></p></li>
  </ol>