JSFiddle - React, Tailwind, and code Playground

HTML

<div class="info_item" id="post1">
      <div name="x" class="item" id="loaded_with_ajax"> 
        
      </div>
   </div>

JavaScript

var html='<h2>Click on this h2 should empty the div with class="item"</h2> <h3>this is a h3</h3>  <p>this is a paragraph</p> ';

$('.item').on('click', "h2", function() {
   $(this).parent().empty();
});
$.ajax({
    url: '/echo/html/',
    type:'post',
    data:{html:html ,
         delay: 3
         },
  
    success: function(response) {
        
       $(".item").html(response);
    }
});