I have 2 jquery vars:
var contVar = $('#container');
var linkNameVar = $(this).attr('id'); //for example <div id="test">
What I need is to combine them to access #container .test, i.e. for it to look like:
$(contVar .linkNameVar)
How do I:
-
add a
.in front oflinkNameto turn it into a class. -
then combine the 2 variables into 1 selector.
I looked at the .add() documentation but it doesn’t seem to be what I need.
Try this, you could use the second parameter as the context for selector.