title: How to change ID to Class in Javascript
body: <p>What do you do to change a javascript from a ID to a Class? I tried to do it on my own but with no luck, this is what I ended up with. The original code was to show or hide an element and remember the users selection.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="popup" style="display:none"&gt;
      &lt;img src="image-url.jpg" alt="alt text" title="title text"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  }
  
  function getCookie (name) {
  
      var cookie = " " + document.cookie;
      var search = " " + name + "=";
      var setStr = null;
      var offset = 0;
      var end = 0;
  
      if (cookie.length &gt; 0) {
          offset = cookie.indexOf(search);
  
          if (offset != -1) {
              offset += search.length;
              end = cookie.indexOf(";", offset);
  
              if (end == -1) {
                  end = cookie.length;
              }
  
              setStr = unescape(cookie.substring(offset, end));
          }
      }
  
      if (setStr == 'false') {
          setStr = false;
      } 
  
      if (setStr == 'true') {
          setStr = true;
      }
  
      if (setStr == 'null') {
          setStr = null;
      }
  
      return(setStr);
  }
  
  function hidePopup() {
      setCookie('popup_state', false); 
      document.getElementsByClassName('popup').style.display = 'none';
  }
  
  function showPopup() {
      setCookie('popup_state', null);
      document.getElementsByClassName('popup').style.display = 'block';
  }
  
  function checkPopup() {
      if (getCookie('popup_state') == null) { 
          // if popup was not closed
          document.getElementsByClassName('popup').style.display = 'block';
      }
  }
  </code></pre>