Alex Rivera | Logout

jQuery selectors with variables

Asked 2011-02-04T00:42:03.477
48

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
Report

1 Answer

3

This might just be a typo or you actually use the id variable in a class, but maybe it should be:

jQuery('#one img #'+id)
answered 2011-02-04T00:43:48.767

Your Answer