[jQuery] Re: Selecting an element whose ID is in a variable

2008-10-28 Thread fredriley
D'OH!! I'd not thought of that, but as you point out, the selector is a string, so it should have occurred to me at some point. Thanks to yourself and Josh for the replies. As it happens, this is a FAQ for a number of programming languages I've used, and I usually end up hunting for an eval() or

[jQuery] Re: Selecting an element whose ID is in a variable

2008-10-28 Thread dabear
In this case you might use that solution (if you can gurantee the id won't mess with the selctor), but I would usually just do a $(document.getElementById(var)); that way you don't have to escape var. imagine you had a div id=foo :first-child) /div then var id=theDiv.attr(id) // id would now be

[jQuery] Re: Selecting an element whose ID is in a variable

2008-10-27 Thread Richard D. Worth
$(# + fieldset_id) - Richard On Mon, Oct 27, 2008 at 4:13 PM, fredriley [EMAIL PROTECTED] wrote: This has got to be a FAQ, but I can't see it in the FAQ so here goes, and apologies if it's a stupid question but I'm a relative newbie to jQuery: How can I select an element whose id is stored

[jQuery] Re: Selecting an element whose ID is in a variable

2008-10-27 Thread Josh Nathanson
You want this: $(# + fieldset_id); Don't feel bad, that trips up a lot of people at first (myself included). Basically the selector is just a string, so you can use the usual JS string methods to get what you need. -- Josh - Original Message - From: fredriley [EMAIL PROTECTED]