If I have HTML such as this:
<ul>
<li id="id1">Some Text</li>
<li id="id2">Other Text</li>
<-- more items could be here -->
</ul>
How can I create a an array containing JSON object with the properties of each list item in the list, something like:
var itemsData = [
{
"id" : id,
"name" : name
},
{
"id" : id,
"name" : name
}
]
Where id and name equal to $(this).attr('id') and $(this).text() where $(this) refers to a single li item.
By using
.each: