JSFiddle - React, Tailwind, and code Playground

by charlescarver

HTML

<div></div>
<br />
<a class="reload">Reload</a>

<br />
<a class="clear">Clear</a>

JavaScript

var title = "Hello";
$("div").text(title);

function test() {
    if (localStorage.getItem(title)) {
        alert("test");
        var n = 1;
        while (localStorage.getItem(title + n)) n += 1;
        title = title + " " + n;
    }
    $("div").text(title);
}

$(".reload").click(function () {
    localStorage.setItem("Hello", "Test");
    test();
});

$(".clear").click(function () {
    localStorage.clear();
    test();
});