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
  • 997
  • 3
  • 8
  • 20

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
  • 24,863
  • 8
  • 29
  • 52