title: Remember state on refreshing - jQuery with cookie
body: <p>I am trying to develop a script that would remember the state after page refresh.</p>
  
  <p>Here is what I've done so far.</p>
  
  <p>jQuery:</p>
  
  <pre><code>      $(window).ready(function() {
  var voteId = $('.gallery-item a');
  $(voteId).click(function() {
  $(this).text('Thank you!');
  $(this).css('background-color', 'green');
  });
  });
  </code></pre>
  
  <p>I have tried this, but didn't have luck with it:</p>
  
  <p>jQuery:</p>
  
  <pre><code>var cookies = document.cookie.split(";");
      for(var i=0; i &lt; cookies.length; i++) {
      var equals = cookies[i].indexOf("=");
      var name = equals &gt; -1 ? cookies[i].substr(0, equals) : cookies[i];
      document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
      }
  </code></pre>