JSFiddle - React, Tailwind, and code Playground
HTML
<button>click</button>
<ul id='theList'>
</ul>
JavaScript
var index=0;
$('button').click(function (e){
$('#theList').append('<span><li class="delete">hello world ' + index+ '</li></span>' );
e.stopPropagation();
index= index+1;
});
$(document).click(function (){ //click anywhere but the button and all <li> items disappear.
$('.delete').remove();
});