Demo (Codepen)<div class="clicker">
<button class="prev">-</button>
<span class="counter"></span>
<button class="next">+</button>
</div>
const counter = document.querySelector(".counter");
let count = parseInt(localStorage.getItem("count") || 0);
counter.textContent = count;
document.querySelector(".clicker").addEventListener("click", event => {
if (event.target.closest(".prev")) {
localStorage.setItem("count", --count);
counter.textContent = localStorage.getItem("count");
}
if (event.target.closest(".next")) {
localStorage.setItem("count", ++count);
counter.textContent = localStorage.getItem("count");
}
}, false);