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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit: Based on your comment below, you would use this:
In your question you have a space between
imgand the.class, I’ve simply removed that so you getimg.classNameorimg.'+classNameWith the introduction of template literals in ECMAScript 2015, you can also do