1

How can I combine a jQuery variable with some css class in the following example:

For example I can use this:

$("#wrapper .box")

But if #wrapper is stored in a variable, like:

var wrapper = "#wrapper";

This will not work:

$("wrapper .box")
0

1 Answer 1

3

In your code, you used it as a string, not a variable. Use the concatenation operation for that.

$(wrapper + " .box")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer and correction, if its string, how to define variable?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.