title: Change CSS Class of Button Using JavaScript
body: <p>Is it possible to change the CSS class of an HTML button using JavaScript?</p>
  
  <p>I tried this but it didn't work:</p>
  
  <pre><code>document.getElementById("btnChoice1").setAttribute("class", "redButton");
  </code></pre>
  
  <p>HTML Button</p>
  
  <pre><code>&lt;button class="basicButton" id="btnChoice1"&gt;
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>.basicButton {
      width:300px;
  }
  
  .redButton {
      width:300px;
      background-color:red;
  }
  </code></pre>