views:

38

answers:

1

Hey all,

I have a simple variable:

var spanId = 'hi';

Now, I want to generate this:

$('#hi')

using the variable.

So I tried:

$('#' + spanId)

But that didn't work. Any suggestions?

Thanks, Amit

A: 
davyM
This is the wrong answer.+ sign would never cause any problems because '#' + spanId would return a string that would then be passed to the $ function.$(query) and $('#' + spanId) are equivalent.There must be some other problem in the code
ovais.tariq
You are right: i posted that '+' is a css selector, and that it "might" be a problem. In the meantime i checked it, and updated my post stating that it isn't a problem
davyM