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!
There’s no native jQuery selector for this. You could write one if you want or just use:
If you want to create your own selector:
And then you can do: