title: Change List Item Color When Checkbox is Selected in Contact Form 7
body: <p>I've been wracking my brain about this problem for a few days now. I'm working on a wordpress site that uses Contact Form 7 (CF7). Basically, I'm trying to change have each list item change color when the checkbox is selected.</p>
  
  <p>This topic has been my main inspiration so far: <a href="https://www.sitepoint.com/community/t/on-click-of-check-box-my-div-border-and-text-color-should-be-in-blue/276230/3" rel="nofollow noreferrer">https://www.sitepoint.com/community/t/on-click-of-check-box-my-div-border-and-text-color-should-be-in-blue/276230/3</a></p>
  
  <p>But I'm unsure of how to get the code to work within the CF7 editor (I've tried the support forums in that plugin, but no one answered me there haha).</p>
  
  <p>Relevant code in CF7:</p>
  
  <pre><code>&lt;span onclick="UpdateFeatures(this,false);"&gt; [checkbox* InterestsAndGoals id:getStartedInterestsAndGoals use_label_element "Growth" "Marketing Exposure" "Increase in overall traffic" "Edge over your competition" "Increase in low season traffic"]&lt;/span&gt;
  </code></pre>
  
  <p>Javascript used in CF7:</p>
  
  <pre><code>&lt;script&gt;
  function UpdateFeatures(checkbox) {
    console.log(document.querySelector(".wpcf7-list-item"));
    document.querySelector(".wpcf7-list-item").classList.remove("changeColor");
    if (checkbox.checked) {
    document.querySelector(".wpcf7-list-item").classList.add("changeColor");
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>#getStartedInterestsAndGoals input[type=checkbox] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
  }
  
  span.wpcf7-list-item {
    display: inline-block;
    margin: 0 0 15px 0;
  }
  
  .wpcf7-list-item {
    margin: 0 0 20px 1em;
    border: 1px solid #f26922;
    border-radius: 40px;
    text-transform: uppercase;
    font-size: 16px;
    padding: 10px;
    width: 100%;
  }
  
  .wpcf7-list-item:hover {
    background-color: #f26922;
    border-color: #333333;
    color: #ffffff;
  }
  .changeColor {
    background-color: #f26922;
    border-color: #333333;
    color: #ffffff;
  }
  </code></pre>
  
  <p>JSFiddle to demonstrate code made from CF7:
  <a href="https://jsfiddle.net/p9wrdsmo/1/" rel="nofollow noreferrer">https://jsfiddle.net/p9wrdsmo/1/</a></p>
  
  <p>Any help with this would be greatly appreciated! I'm not very good at JavaScript and would have preferred pure HTML/CSS, but I don't believe it's possible.</p>
  
  <p>Thank you!!</p>