anonymous anonymous - 2 months ago 7x
jQuery Question

jQuery selectors with variables

How to mix variables with selectors?

I have ID variable.

I want to select image with this id from div #one.

jQuery('#one img .id')
is the selector. I've tried
$('#one img .'+id)
but doesn't work.


Edit: Based on your comment below, you would use this:

$('#one img.'+id)

In your question you have a space between the img & the .class, I've simply removed that so you get img.className or img.'+className