I have a situation where I have two arrays of objects. I want select same objects from both arrays and show it. For instance I have following UL (You can see it at jsFiddle):
<ul>
<li id="one" class="color pro">one</li>
<li id="two" class="color pro">two</li>
<li id="three" class="color">three</li>
<li id="four" class="color">four</li>
</ul>
I am using following script to show same objects.
var activeElementsColors = $("ul li.color");
var activeElementsPro = $("ul li.pro");
var activeElements = activeElementsPro.filter(function(el) {
return $.inArray(el, activeElementsColors) > -1;
});
activeElements.show();
I know I can use $("li.color.pro").show() but above one is just an example. real code is complex than this.
$("ul li.color")will already give you both sets combined.