Link to home
Start Free TrialLog in
Avatar of mickey159
mickey159Flag for United States of America

asked on

How to insert variable into jQuery gt() selector

Please help me to insert a variable to the gt function.
Example:
var something=1;
$("img:gt(something)").attr("something","something");

Thanks
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mickey159

ASKER

So I can just treat any selector like a string and use it with variables?
That's great news.
Also thanks for your code.
It works!!!
And one more question:
How can I use multi selectors with the selector mentioned above?
Something like $(this,"img:gt("+something+")")?
I tried this but it fails.

Thanks!
>So I can just treat any selector like a string and use it with variables?

Yes?

var myString = ".aClassSelector";
$(myString).toggle();

>How can I use multi selectors with the selector mentioned above?
$("img:gt("+something+")", $(this))
Thanks and you are wonderful!
Thanks
You're welcome! Thanks for the points!