JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<img src="whatever" alt="test" onclick="doClose('test')" />
</div>
JavaScript
function doClose(template) {
console.log(template);
$('body').find('img[alt="'+template+'"]').remove();
}