JSFiddle - React, Tailwind, and code Playground
HTML
<button>Кнопка #1 | нажатий: 0</button>
<button>Кнопка #2 | нажатий: 0</button>
CSS
button {
margin: 20px;
}
JavaScript
const buttons = document.querySelectorAll('button');
buttons.forEach(button => button.addEventListener('click', buttonsHandler));
function buttonsHandler({target}) {
target.textContent = target.textContent.replace(/(?<=нажатий: )\d+/, (count) => Number(count) + 1);
}