JSFiddle - React, Tailwind, and code Playground
HTML
<div id='target'>
<p>Click me. This text will be replaced in 5 seconds.</p>
</div>
JavaScript
$('p').on('click', function(e) { alert('I was clicked.');});
$.ajax({
url: '/echo/html/',
type: 'POST',
data: {
html: "<p>Why doesn't the click handler fire anymore?</p>",
delay: 5
},
dataType: 'html',
success: function(data, textStatus, jqXHR) {
$('#target').html(data);
}
});