title: Local Storage Jquery
body: <p>I'm working on local storage using jQuery. I've got an input field in which you can type some text, press enter, refresh and the text is still there. So that's working fine.</p>
  
  <p>But I want to combine it with a different function I wrote. In this function a user can click on a grey button which will then "activate" it so it turns red, and it will add a 1 to the container. It's a "like button".</p>
  
  <p>So how can I save the click counter information (button turning red, and value updated) using local storage? </p>
  
  <p>I made this jsfiddle: <a href="http://jsfiddle.net/Yazuri/7ZxMK/" rel="nofollow">http://jsfiddle.net/Yazuri/7ZxMK/</a> </p>
  
  <pre><code>jQuery(function ($) {
  
    if (typeof (window.localStorage) != "undefined") {
  
  
        $("input[type=text]").val(function () {
            return localStorage.getItem(this.id);
        });
  
        $("input[type=text]").on("change", function () {
            localStorage.setItem(this.id, $(this).val());
        });
    }
  });
  </code></pre>