JSFiddle - React, Tailwind, and code Playground
HTML
<div class="boots"></div>
CSS
.push {
outline: dashed 1px gray;
padding: 5px;
margin: 5px;
}
JavaScript
const container = document.querySelector(".boots");
createButtons(container, 6);
container.addEventListener('click', function(evt) {
const pushElem = evt.target.closest('.push');
if (pushElem) {
saySomething();
}
})
function createButtons(container, buttonsCount) {
let html = '';
for (let i = 0; i < buttonsCount; i++) {
html += '<div class="push"><button>нажми</button></div>';
}
container.innerHTML = html;
}
function saySomething() {
console.log("good");
}