zazvorniki
zazvorniki

Reputation: 3602

Counting Specific text on a page

I have an html document that has a 'status' column. I need to count how many of these are marked Available or not Available.

I've tried to do something like this

$("td:contains(Available)" ).length;

but this is also picking up the "Not Available"'s. Is there a way to only select the Available's?

A example of the web page http://www.cats-can.org/animals/list?Species=Cat

Upvotes: 0

Views: 41

Answers (1)

dave
dave

Reputation: 64707

You could do:

$("td:contains(Available)" ).length - $("td:contains(Not Available)" ).length;

If the only text in the column is "Available", you could do:

$("td").filter(function() {
    return $(this).text() === "Available";
}).length;

Upvotes: 1

Related Questions