Counter

HTML

<div id="counter">
  <p id="count-display">0</p>
  <button>Добавить</button>
</div>

CSS

body {
  padding: 20px;
  font-family: Helvetica;
}

#counter {
  text-align: center;
}

#count-display {  
  font-size: 25px;
  text-align: center;
  transition: all 0.2s;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;
  margin: auto;
}

#banner-message.alt {
  background: #0084ff;
  color: #fff;
  margin-top: 40px;
  width: 200px;
}

#banner-message.alt button {
  background: #fff;
  color: #000;
}

JavaScript

// find elements
var display = $("#count-display")
var button = $("button")

function makeCounter() {
  let x = 0;
  return function () {
    x = x + 1;
    return x;
  }
}

let counter = makeCounter();

// handle click and add class
button.on("click", () => {
  display.text(counter());
})