JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" id="test" /> Check me
<div id="items"></div>
JavaScript
$("#test").bind('click', function() {
var $t = $(this);
if ($t.is(':checked')) {
// append item
$('#items').append('<span>I was recently appended.</span>');
}else{
// empty div and remove it from DOM (empty helps with memory leak issues with $.fn.remove() )
$('span', '#items').empty().remove();
}
});