Jquery - putting variables in :contains()

Posted by Pete B on Stack Overflow See other posts from Stack Overflow or by Pete B
Published on 2010-03-29T02:47:14Z Indexed on 2010/03/29 2:53 UTC
Read the original article Hit count: 370

Filed under:

I am trying to write a simple piece of Jquery in which the script will check whether a table cell contains a range of numbers.

I'm unsure how to do this, because if you were to do something like this:

var num_range = ">1";
$("td:contains(" + num_range + ")").css('background-color', '#000');

...the script only detects if the td contains the exact text ">1", rather than what I'm after, it detecting whether any tds contain any numbers greater than 1. (Any then styling the background)

Thanks for any help, I'm a Javascript/Jquery novice!

© Stack Overflow or respective owner

Related posts about jQuery