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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
please note that the “+”-sign is a css selector, this might be a problem.
__________________ UPDATE __________________
I quickly checked it (See http://jsfiddle.net/r7MgY/1496/), it seems to work.
Code:
html (in body):
css:
jquery: