JSFiddle - React, Tailwind, and code Playground

by Alexander

HTML

<input type="text" value="">
<div></div>

JavaScript

console.clear();

var $ = document.querySelector.bind(document);
Element.prototype.on = Element.prototype.addEventListener;

function _$(selector, ctx) {
	return (ctx || document).querySelector(selector);
}

// selects all nodes matched given selector
function $$(selector, ctx) {
	return [].slice.call((ctx || document).querySelectorAll(selector));
}

var $div = $("div"),
    $input = $("input");

$input.on("keypress", function(){
    $div.innerText = $input.value;
    localStorage.myData = $input.value;
});

window.addEventListener("storage", function(e){
    $div.innerText = localStorage.myData;
}, false);