I have this:
<div class="graph">
<rect y="2%" class="rect"></rect>
<text>1</text>
<rect y="15%" class="rect"></rect>
<text>2</text>
<rect y="11%" class="rect"></rect>
<text>3</text>
</div>
And an array like this: var labels = ["one", "two", "three"];
And I do this:
labels.forEach(function (label, index) {
if (index == 0) {
// get first rect and text tag
} else if (index == 1) {
// get second rect and text tag
} else {
// get third rect and text tag
}
})
I would like to get in first iteration the first "rect" HTML tag and the first "text" HTML tag; in the second iteration the second and in the third iteration the third.