so let's say I have some jQuery that runs as follows:
var myVar1 = $('.myClass1, .myClass2');
myFunction(myVar1); // Does something to element myVar1
var myVar2 = $('#myId').parent();
myFunction(myVar2); // Does something to element myVar2
Here's the problem. Sometimes #myId's parent will be its own element, but it will sometimes also have either class .myClass1 or .myClass2. However, I don't want to run myFunction() on #myId's parent twice.
So the html could either be like:
<div class="myClass1"></div>
<div class="myClass1"></div>
<div class="myClass2"></div>
<div>
<div id="myId"></div>
</div>
Or it could be like this:
<div class="myClass1">
<div id="myId"></div>
</div>
<div class="myClass1"></div>
<div class="myClass2"></div>
The jQuery needs to call the function on each <div> only once.
How do I detect if myVar2 is contained within myVar1?
oneandtwobemyVar1andmyVar2?