Reputation: 13295
I have two arrays. One looks like this:
var array_one = [".a", ".b", ".c", ".d"];
.a
, .b
, .c
& .d
are CSS-classes that can be found in the DOM.
Then I got another array array_two
which holds all elements with class .lorem
currently in the DOM.
Now how do I find the elements that have .a
, .b
, .c
or .d
and .lorem
by comparing the two arrays?
Upvotes: 1
Views: 107
Reputation: 146310
Assuming array_two
is a jQuery object you can do:
array_two.has(array_one.join(","));
This is using the .has(...)
jQuery function.
Upvotes: 0
Reputation: 75317
You can use the jQuery's filter()
method, coupled with Array's join()
;
$(array_two).filter(array_one.join(","));
Upvotes: 3