title: How to use css variable colors and js to change div background
body: <p>So this is a very basic function (found and edited for my purposes) that alternates the div background color to white or black.</p>
  
  <p>I would like to change the code to utilize the css variables I have in the root property and have no onClick functions inside the html. I want to keep html and js seperate, but I don't know how to go about this.</p>
  
  <p>Can I have two buttons that can switch between the css variable colors for the div?</p>
  
  <p>Thank you.</p>
  
  <p><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>function changeColor(color) {
    var element = document.getElementById('box');
    element.style.backgroundColor = color;
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>root {
    --white { color: #fff}
    --black { color: #000}
  }
  
  .box {
    width: 100px;
    height: 100px;
    border: 1px solid #aaa;
    background-color: #fff;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="box" id="box"&gt;
  &lt;/div&gt;
  
  &lt;button onClick=changeColor('white')&gt;white&lt;/button&gt;
  &lt;button onClick=changeColor('black')&gt;black&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>