Hi there,

I'm not sure, but it could be that the .eq() method is expecting an integer only.

Have you tried it this way instead?

$("#"+menu+" .itemMenu li:eq("+item1+")").addClass("highlight");

that should do t he trick.


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Nov 21, 2007, at 8:19 PM, pcadi wrote:


Hi,

I have the weirdest of bug. If I do:

var item1 = 3;

$("#"+menu+" .itemMenu li").eq(item1).addClass("highlight");

Then all the li elements get highlighted.

If I do:

$("#"+menu+" .itemMenu li").eq(3).addClass("highlight");

it works fine.

How do I use a variable in a jquery query?

Thanks in advance,

P.

Reply via email to