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
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
$(# + 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
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]
4 matches
Mail list logo