title: Js remove all classes from element
body: <p>I have a button and when I click on it I want to remove all the classes. That's what I've tried so far:</p>
  
  <pre><code>button.style.className = ''
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.querySelector('button').onclick = function() {
    this.style.className = '';
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.myClass {
  
    color:red;
    
  }
  
  .second {
  
    color:green;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button class="myClass second"&gt;click me&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now I can't use classList.remove because I doen't know the class names, they are dynamic.</p>
  
  <p>How can I remove all the classes from an element?</p>