JSFiddle - React, Tailwind, and code Playground
by franknstayn
HTML
<div class="img-wrap">
<span class="close">×</span>
<img src="http://lorempixel.com/200/200" data-id="123">
</div>
<div class="img-wrap">
<span class="close">×</span>
<img src="http://lorempixel.com/100/80" data-id="103">
</div>
CSS
.img-wrap {
position: relative;
display: inline-block;
border: 1px red solid;
font-size: 0;
}
.img-wrap .close {
position: absolute;
top: 5px;
right: 5px;
z-index: 100;
background-color: #FFF;
padding: 5px 2px 2px;
color: #000;
font-weight: bold;
cursor: pointer;
opacity: .2;
text-align: center;
font-size: 22px;
line-height: 10px;
border-radius: 50%;
}
.img-wrap:hover .close {
opacity: 1;
}
JavaScript
$('.img-wrap .close').on('click', function() {
var id = $(this).closest('.img-wrap').find('img').data('id');
alert('remove picture: ' + id);
});