jQuery Find the specific text in the page

jovenne

I want to redirect the user automatically into another page if this text exist 'Shopping Cart is Empty'. I found this jQuery :contains() Selector and test on it but It didn't work. Here's my code:

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

<script>
 $( "div.page-title:contains('Shopping Cart is Empty')".window.location.replace("http://www.another-page.com");
</script>
Tushar Gupta - curioustushar

Fiddle DEMO

$(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");
    }
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jquery redirect user to specific page

From Dev

Using jQuery to find list items containing specific text in nested lists

From Dev

Find a table containing specific text

From Dev

jQuery - Find specific class and remove it

From Dev

Find specific sentence in a web page using powershell

From Dev

find url of a specific wordpress page

From Dev

find percentage of page height jquery

From Dev

find and replace text jquery

From Dev

Find a specific text in tr td jquery using contains

From Dev

Find specific text in a paragraph by line

From Dev

get a specific text of an anchor - jquery

From Dev

Jquery find td with a specific value

From Dev

Find specific lines in text document

From Dev

CommonCrawl: How to find a specific web page?

From Dev

Find specific table row containing substring text of a jquery variable of html

From Dev

JQuery: How to find multiple specific checkbox id's in a page of switchable checkboxes

From Dev

Jquery Find a specific class with a specific attribute value

From Dev

How to find a specific text in files with specific extension?

From Dev

jquery redirect user to specific page

From Dev

Find specific string with jquery

From Dev

jQuery : Find text after a string of specific tags and remove img tags if no images

From Dev

jQuery find text and hide that text

From Dev

remove specific text from html page using jquery

From Dev

Find a table containing specific text

From Dev

Select a specific text in jquery

From Dev

Find a specific text in tr td jquery using contains

From Dev

Jquery code not working on specific page

From Dev

Find specific table row containing substring text of a jquery variable of html

From Dev

Replace specific text using jquery

Related Related

HotTag

Archive