JSFiddle - React, Tailwind, and code Playground
HTML
<button>test</button>
<ul>
<li>
<a href="#">1</a>
<a href="#">2</a>
</li>
<li>
<a href="#">1</a>
<a href="#">2</a>
</li>
</ul>
JavaScript
$('ul').on("click", "li a:last-child", function(event) {
alert("test");
});
$('button').click(function() {
$('li').each(function() {
var $this = $(this),
cnt = $this.children().length;
$('<a href="#" />').html(cnt + 1).appendTo($this);
});
});