On Jan 30, 2008, at 10:24 AM, studiobl wrote:


I'm having trouble with a jQuery selector that contains a variable.
I'm trying to target an element that has a class of "orderInfo" and an
id of "billy"

So, I set a variable:

var tabText = "billy";

...and it works if I use the string:

$(".orderInfo[id='billy'"];

...but not the variable:

$(".orderInfo[id=tabTest"];


...but of course I need it to work with a variable {insert appropriate
emoticon here}

Hi there,

The trick here is to concatenate the variable with the selector string. Something like this should work:

$(".orderInfo[id=" + tabTest + "]");


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

Reply via email to