JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<button id="download">DOWNLOAD</button>
<span class="text-small">
(<span id="result"></span> Downloads)
</span>
</div>
CSS
.text-small { font: 11px/1.4 sans-serif; }
JavaScript
function clickCounter() {
// Read fron localstorage or fallback to 0
document.getElementById("result").innerHTML = localStorage.clickcount || 0;
}
document.getElementById("download").addEventListener("click", function() {
localStorage.clickcount = Number(localStorage.clickcount) + 1;
clickCounter(); // Do on click
});
clickCounter(); // and on DOM ready