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
$("#" + clickid).click();
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:
- jQuery ID Selector
精彩评论