JSFiddle - React, Tailwind, and code Playground

HTML

<div id='iam'>
    I'am div
</div

CSS

div{
    background-color: red;
}

.anim {
    -webkit-animation: bgcolor 1s;
    -webkit-animation-direction: alternate;
}

@-webkit-keyframes bgcolor {
from{
    opacity:1;
}
    
    to{
    opacity:0;
   }
}

JavaScript

$('#iam').addClass('anim');
setTimeout(function(){
    $('#iam').hide();
},990);