title: JavaScript classList not working while clicking a button
body: <p>I am currently creating a dropdown menu so I want the menu to be displayed when clicked by adding class via Javascript but classList is not working at all. I tried lots of time but couldn't. Also if i add <code>style.display = "block"</code>, then it works! I am unable to figure out! Please Help me!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.getElementById('dbtn').addEventListener('click', function() {
    document.getElementById('d-content').classList.toggle('show');
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#wrapper {
    position: relative;
    display: inline-block;
  }
  
  #dbtn {
    background-color: #F44336;
    font-size: 27px;
    font-family: 'Droid Sans', sans-serif;
    border: none;
    padding: 0.3em 0.6em;
    color: #FFFFFF;
    cursor: pointer;
    outline: none;
  }
  
  #d-content {
    position: absolute;
    display: none;
    background-color: #F44336;
    font-family: 'Droid Sans', sans-serif;
    font-size: 22px;
    border-top: 2px solid #FFFFFF;
    z-index: 1;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  }
  
  #d-content a {
    color: #FFFFFF;
    text-decoration: none;
    display: block;
    padding: 0.3em 5em 0.3em 0.3em;
  }
  
  #d-content a:hover {
    background-color: darkorchid;
  }
  
  .show {
    display: block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Dropdown Menu&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div id="wrapper"&gt;
      &lt;input type="button" id="dbtn" value="Select..." /&gt;
      &lt;div id="d-content" class="drop"&gt;
        &lt;a&gt;USA&lt;/a&gt;
        &lt;a&gt;Canada&lt;/a&gt;
        &lt;a&gt;Europe&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>