title: Javascript set button active
body: <p>I have a table of buttons and once it is populated, I am using</p>
  <pre><code>document.getElementById(&quot;btn0&quot;).click();
  </code></pre>
  <p>to click the first button. The button is doing what it should do, but the background color of the button is not changing the same way it does when I am clicking it manually.</p>
  <p>As you can see when its running, the background-color of the div is changing, but the button is not set to active.</p>
  <p>Code Snippet:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var myfunc = function(){
      document.getElementById("test").style.backgroundColor="red";
  };
  
  document.getElementById("btn0").click();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.btn{
    border: none;
    color: white;
    width: 100%;
    padding: 5px 5px 5px 5px;
    height: 50px;
    cursor: pointer;
    font-size: 12px;
    background-color: #343a40;
  }
  
  .btn:active .btn.active{
    background-color:green;
    outline: none;
  }
  
  .btn:focus{
    background-color:green;
    outline: none;
  }
  
  #test{
    background-color: green;
    width: 600px;
    height: 400px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button class="btn" onclick="myfunc()" id="btn0"&gt; Cool button&lt;/button&gt;
  
  &lt;div id="test"&gt;
    Hello
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Here is a link to a jsfiddle I created:
  <a href="https://jsfiddle.net/58hrwcgo/3/" rel="nofollow noreferrer">https://jsfiddle.net/58hrwcgo/3/</a></p>