JSFiddle - React, Tailwind, and code Playground
by User86745458
HTML
<button id="display">Display</button>
<div class="main">
<ul>
</ul>
</div>
<p id="show"> </p>
JavaScript
var i = 1;
$('#display').click(function() {
$(".main ul").append(
$('<li>').attr("id",i).append(
$('<p>').append("Stackoverflow")
));
i++;
});
$('.main').on('click', 'ul li', function () {
$('#show').html("List ID =" + this.id);
});