JSFiddle - React, Tailwind, and code Playground

window.location.replace works in jsfiddle and also SO-19702224

by dledle2

HTML

<div class="page-title">
    
<h1>Shopping Cart is Empty</h1>

</div>

JavaScript

$(function () {
    var len = $("div.page-title h1").filter(function () {
        return this.innerHTML === "Shopping Cart is Empty";
    }).length;
    if (len > 0) {
        window.location.replace("http://www.another-page.com");
    }
});