JSFiddle - React, Tailwind, and code Playground
HTML
<div id='elementID'>
<span class='elementClass'>Some text</span> <!-- already present -->
<span class='elementClass'>Some text</span> <!-- already present -->
<span class='elementClass'>Some text</span>
</div>
CSS
span{
display: block;
}
JavaScript
$('#elementID').click(function() {
$('span:first', this).clone().text('Some text' + (+$('span:last',this).index() + 1) ).appendTo(this);
});
$('#elementID').on('DOMNodeInserted', function(e) {
console.log($(e.target).text());
});