// HTML
// Some Html content
<div class="class--1 common-class otherClass2">…</div>
// Some Html content
<div class="otherdiv"></div>
<div class="common-class class--2">…</div>
<div class="common-class class--3 otherClass">…</div>
// Some Html content
i'm trying to iterate between 2 arrays; one with className stored and the other with html elements targeted
// JAVASCRIPT
var arrayOfClasses = ["class--5", "class--10", "class--1", "class--2"];
var arrayOfElements = document.getElementsByClassName("common-class");
// This return the following array
// [<div class="common-class class--1">…</div>, <div class="common-class class--2>…</div>, <div class="common-class class--3>…</div>];
How i get true value for the element with class--1 and class--2 and false for class--3 class--5 and class--10
I iterate throw the arrayOfElements[i].className
and after use the indexOf commented below
but found another problem here :S
"common-class class--10".indexOf("class--1")
// Return > 13 but i want -1 because is 10 no 1
Better without jQuery Thanks in advance.