JSFiddle - React, Tailwind, and code Playground
HTML
<div>Old stuff</div>
<div>Old stuff</div>
<div>Old stuff</div>
<div id="newContent">New stuff, just added</div>
<input type="button" value="test" />
CSS
.backgroundAnimated{
background-color: #AD310B !important;
background-image:none !important;
-webkit-transition: background-color 5000ms linear;
-moz-transition: background-color 5000ms linear;
-o-transition: background-color 5000ms linear;
-ms-transition: background-color 5000ms linear;
transition: background-color 5000ms linear;
-webkit-animation-direction: alternate; /* Chrome, Safari, Opera */
animation-direction: alternate;
-webkit-animation-iteration-count: 2; /* Chrome, Safari, Opera */
animation-iteration-count: 2;
}
.nextBackgroundAnimated{
background-color: white !important;
background-image:none !important;
-webkit-transition: background-color 5000ms linear;
-moz-transition: background-color 5000ms linear;
-o-transition: background-color 5000ms linear;
-ms-transition: background-color 5000ms linear;
transition: background-color 5000ms linear;
-webkit-animation-direction: alternate; /* Chrome, Safari, Opera */
animation-direction: alternate;
-webkit-animation-iteration-count: 2; /* Chrome, Safari, Opera */
animation-iteration-count: 2;
}
JavaScript
$('input[type=button]').click( function() {
$('#newContent').addClass('backgroundAnimated');
setTimeout(function(){
$('#newContent').addClass('nextBackgroundAnimated');
}, 5000);
});