title: localStorage, saving a class using toggleClass
body: <p>I am  clueless when it comes to localStorage it seems. I want to set up a way favorite any div in a group of div's by toggling a class. I can get the toggleClass to work on the individual div and be saved but localStorage saves all the div's as favorites, not just the one with the toggleClass set. Obviously I am missing something.</p>
  
  <p><a href="http://codepen.io/macsupport/pen/WvmOBE" rel="nofollow">jsfiddle simple example</a> </p>
  
  <p>localStorage code:</p>
  
  <pre><code>if (typeof (localStorage) == 'undefined') {
  document.getElementById("result").innerHTML = 'Your browser does not support HTML5 localStorage. Try upgrading.';
  } else {
  if (localStorage.getItem("fav") != null) {
      getFav = localStorage.fav;
      $(".item").addClass('favorites');
  }
  }
  $(document).ready(function () {
  $('.btn').on('click', function () {
      getFav = localStorage.fav;
      //$(".item").removeClass('favorites');
      //localStorage.removeItem('background');
      $(this).closest(".item").toggleClass('favorites');
      if ($(this).closest(".item").hasClass('favorites')) {
      localStorage.setItem('fav', 'favorites');
  
  }else{
      localStorage.removeItem('fav');
  }
  
  });
  });
  </code></pre>
  
  <p>The issue resides in</p>
  
  <pre><code>$(".item").addClass('favorites');
  </code></pre>
  
  <p>It adds the class to all .items and obviously it should not.</p>
  
  <p>Any help would be appreciated!</p>