tags:

views:

39

answers:

2

I have a div in which id is generated with index like gal1,gal2,gal3,gal4....

var clickid="gal" + index;
$('WANT TO PLACE clickid HERE').click();

I want to place the clickid variable inside the jquery selector. How to achieve it. This questions looks silly, but im a beginner eager to learn

+6  A: 
$("#" + clickid).click();
Alex Reitbort
Thanks for your immediate response and help
Rajasekar
+3  A: 

Like this:

$('#' + clickid).click();

Since it is an id, you need to prepend # to it so that jQuery is able to find it out. This is similar to CSS :)

For more info, have a look at:

Sarfraz
+1 Deserved one more plus 1;
KMan