JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<p>Some text</p>
</div>
<button>Add</button>
CSS
@keyframes flash {
0% {
opacity: 1;
}
50% {
opacity: 0.3;
}
100% {
opacity: 1;
}
}
.flash {
animation-name: flash;
animation-duration: 500ms;
animation-iteration-count: 2;
}
JavaScript
var div = document.querySelector('div')
var button = document.querySelector('button')
button.addEventListener('click', function () {
var p = document.createElement('p')
p.textContent = 'Some more text'
p.className = 'flash'
div.append(p)
})