JSFiddle - React, Tailwind, and code Playground

HTML

<button>Add
</button>

<div id="contain">
</div>

CSS

.div {
  width: 100px;
  height: 50px;
  background: #000;
  margin-top: 50px;
}
.nested {
  width: 50px;
  height: 25px;
  background: red;
  z-index: 100;
  margin-top: -25px;
  cursor: pointer;
}

JavaScript

$('button').click(function() {
	$('#contain').append('<div class="div"></div>').append('<div class="nested"></div>');
});

$('.nested').click(function() {
	$(this).parent().remove();
});