JSFiddle - React, Tailwind, and code Playground

by shapeshifta

HTML

<input type="text" class="js-cache" id="test"/>

JavaScript

$('input.js-cache')
  .on('keyup input', function() {
    localStorage[this.id] = this.value;
  })
  .each(function() {
    if (localStorage[this.id]) {
      $('#' + this.id).val(localStorage[this.id]);
    }
  });