JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container"></div>
<button id="start">Start</button>
JavaScript
var TOTAL = 50;
$('#start').on('click', function(){
start();
});
function start(){
for(var i = 0; i < TOTAL; i++){
$('#container').append('<div id="num_' + i + '" class="person"> Person ' + i + '</div>');
}
personEvent();
}
function personEvent(){
$('.person').on('click', function(){
alert('You clicked me: ' + $(this).text());
});
}
$('#num_42').click();