Lets say I have two variables defining separate selectors, for example…
var parent = $('.parent');
var child = $('.child');
And I want to create a something like the following…
$(parent + child).click();
Which should be equivalent to doing this (if it was correct syntax)…
$('.parent .child').click();
This may not be best practice, however I am curious if it is possible. Thanks for your help in advance.
You can pass a jQuery object to use as
contextin another selector, using$( selector [, context] ):$(child, parent)is the equivalent of$(".parent .child").DEMO.