title: Multiple DIVs with same class with each toggling independently between 2 DIVs
body: <p>I have multiple divs with the same class (.item) and trying to figure out how to independently toggle between 2 divs (#open and #close).</p>
  
  <p>For example, clicking on "A" or "B" toggles between "Open" and "Close" independently. </p>
  
  <p>I've tried placing "(this)" before (.item), but it results in toggling not working at all.</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>$(this).on("click", function(event) {
    $(event.target).closest(".item").toggleClass("highlight").toggleClass("marked unmarked");
    if ($(".item").hasClass('unmarked')) {
      $("#open").show();
      $("#close").hide();
    } else if ($(".item").hasClass('marked')) {
      $("#close").show();
      $("#open").hide();
    } else {
      $("#close").hide();
      $("#open").hide();
    }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.item {
    text-align: center;
    margin: 5px;
    padding: 5px;
    background: #EEEEEE;
  }
  
  .highlight {
    background: orange;
  }
  
  #open,
  #close {
    display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div class="item marked"&gt;A&lt;/div&gt;
  &lt;div class="item marked"&gt;B&lt;/div&gt;
  &lt;div class="item marked"&gt;C&lt;/div&gt;
  &lt;div id="open"&gt;Open&lt;/div&gt;
  &lt;div id="close"&gt;Close&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>