There is a jQuery :gt() selector which allows to select all elements at an index greater than index within the matched set.
I can use it like this:
$(this).find('a:gt(30)');
The problem is that I’m using a var instead:
var opt = $("#div").text();
How do I set the :gt() selector next to the variable:
var opt = $("#div").text();
$(this).find(opt:gt(30));
This doesn’t seem to work.
You just need to use string concatenation.
If
opthas a value of, for example,"a". Then the expressionopt + ":gt(30)"will evaluate to"a:gt(30)".You need to be careful that
optis a valid selector.