JSFiddle - React, Tailwind, and code Playground

by Dwza

HTML

<span> added to your shopping cart.</span>
<div id="header-cart">I am the TargetDiv</div>

CSS

.skip-active{ 
    background: red;
}

JavaScript

$(document).ready(function () {

    var sText     = " added to your shopping cart.";
    var target    = "#header-cart";
    var tempClass = "skip-active";
    
    if ($("span:contains('" + sText + "')").length > 0) {
        $(target).addClass(tempClass);
        setTimeout(function () {
            $(target).removeClass(tempClass);
        }, 5000);
    }
});