JSFiddle - React, Tailwind, and code Playground
HTML
<p>Click the blue (child) div to match the background of the parent</p>
<div class="parent">
<div class="child">
</div></div>
CSS
.parent {
width: 100px;
height: 100px;
background: red;
}
.child {
width: 50px;
height: 50px;
background: blue;
}
JavaScript
$('.child').on('click', function(event) {
var bg = $(this).parent().css("background-color"); // finds background color of parent
$(this).css("display",'none'); // applies background color to child
});