this should be fairly simple for those of you who understand jQuery.
I am trying to get this script to run ONLY if <span class="site-header__cart-indicator "></span>
is present on the loaded page.
Here is the untouched jQuery code:
window.setTimeout(redirectCheckout, 2000);
function redirectCheckout() {
if (!(window.location.href.includes("?1"))) {
window.location.href = "https://www.example.com/checkout";
}
}
So here is my version of the code but it doesn't seem to be working:
if (!(window.location.includes("<span class="
site - header__cart - indicator "></span>")))
window.setTimeout(redirectCheckout, 2000);
function redirectCheckout() {
if (!(window.location.href.includes("?1"))) {
window.location.href = "https://www.example.com/checkout";
}
}
Can anyone tell me why my code isn't working? What would be the correct code?