I have a jQuery filter on a set of elements that check to see which items are under the value of 90 and over 100. What I want to do is also get the number of items that match those conditions and eventually save them for output somewhere else on the page:
$("#dtarget li").filter(function()
{
if (parseInt(this.innerText) < 90)
{
$(this).css("color","red");
}
else if (parseInt(this.innerText) > 100)
{
$(this).css("color","gold");
}
});
I’m new to jQuery and Javascript, so be easy.
http://api.jquery.com/length
You can call
.lengthon a jQuery object to get the number of DOM elements it contains.This can then be done for anything greater than 100 as well.
Notice that I removed
this.innerTextin favor of$(this).text()since you are already using jQuery you might as well get all you can out of it.Here is a demo: http://jsfiddle.net/acyZC/1/