I have DOM element in array
this.object =
<div>
<span class="color">"color1</span>
<span class="text">text1</span>
</div>
<div>
<span class="color">"color2</span>
<span class="text">text2</span>
</div>
<div>
<span class="color">"color3</span>
<span class="text">text3/span>
</div>
<div>
<span class="color">"color4</span>
<span class="text">text4</span>
</div>
this DOM is exist in array of DOM ( this.object )
How I update only the first span or only the second span in the array, I can’t use ID from technical issue of my program.
I tried to use
this.element.children[i] but then I didn’t know how to find the first or second span
Use jQuery to avoid any cross browser issues. Assuming you have the div, use
div.find('span:eq(1)');Working example.
Working example for multiple items.
Another example showing the text being updated.