I want to dynamically create an array of objects.
The array will be called 'groups'. It will contain an unknown number of objects (these are the Group Names) which will be determined by the ID of an element. Each object will contain an unknown number of properties (these are the Group Properties), these will be determined by the inner text of a div and their value will be determined by the inner text of another div.
I know how to get each of these values using .each() and .attr('ID') and .text(). I just can't work out how to create the array of objects.
// Example HTML
<div id="england">
<div class="property">health</div>
<div class="count">3</div>
<div class="property">education</div>
<div class="count">1</div>
<div class="property">entertainment</div>
<div class="count">12</div>
</div>
<div id="scotland">
<div class="property">geography</div>
<div class="count">5</div>
<div class="property">history</div>
<div class="count">2</div>
</div>
<div id="wales">
<div class="property">illustration</div>
<div class="count">4</div>
<div class="property">business</div>
<div class="count">6</div>
<div class="property">fashion</div>
<div class="count">3</div>
</div>
.
// Example JSON output of the 'groups' array
{
"england":{
"health":"3",
"education":"1",
"entertainment":"12"
},
"scotland":{
"geography":"5",
"history":"2"
},
"wales":{
"illustration":"4",
"business":"6",
"fashion":"3"
}
}