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")
sam
  • 1,027
  • 3
  • 11
  • 21

1 Answers1

3

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

$(wrapper + " .box")
Anoop Joshi P
  • 25,373
  • 8
  • 32
  • 53