user376539
user376539

Reputation: 55

jQuery access element by id

This may be a simple question. I need to access an html element using jQuery in the following way:

var element_ID = "my" + "name" +"xyz";

Now I want to access/manipulate the element whose ID I have stored in 'element_ID' as above.

This doesn't work : $('#element_ID')

Please let me know the correct way to access the element stored 'element_ID' variable.

-Vijay

Upvotes: 3

Views: 2150

Answers (1)

deceze
deceze

Reputation: 522081

Just use string concatenation once more...

$('#' + element_ID)

Upvotes: 8

Related Questions