title: Toggle classname onclick JavaScript
body: <p>I am nearly there, just a little unsure as to my code setup, I basically want to remove a class on click, and add it back again onclick, then remove onclick, then add onclick. And so on! Here's what I have, it's nearly there, but if there is a nicer way to do this then please help! Thank you.</p>
  
  <pre><code>document.getElementById('myButton').onclick = function() {
      myButton.className = myButton.className.replace(/(?:^|\s)active(?!\S)/g, '') ? 'active': jbar.className.replace(/(?:^|\s)active(?!\S)/g, '') ;
  }
  </code></pre>
  
  <p>Any help much appreciated!</p>