I have HTML data in the following format:
<section class="data">
<div class="colors">
<span class="Red"></span>
<span class="Green"></span>
</div>
<div class="colors">
<span class="Red"></span>
<span class="Blue"></span>
<span class="Green"></span>
</div>
<div class="colors">
<span class="Blue"></span>
<span class="Purple"></span>
<span class="Yellow"></span>
<span class="Black"></span>
</div>
</section>
<section class="results"></section>
There could be any number of elements with a class of "colors" and any number of spans inside every "colors" element.
How can I loop through the data with JS/jQuery and append the same data but in a different new format in the "results" section, like this:
<section class="results">
<p>Red Green</p>
<p>Red Blue Green</p>
<p>Blue Purple Yellow Black</p>
</section>
Would I need to construct an array within an array, where the first level would contain the parents and the second level would contain the values? And if so, what would the syntax be?
Thanks.