如果我有这样的 HTML:
<ul>
    <li id="id1">Some Text</li>
    <li id="id2">Other Text</li>
    <-- more items could be here -->
</ul>
如何创建一个包含 JSON 对象的数组,其中包含列表中每个列表项的属性,例如:
var itemsData = [
    {
         "id" : id,
         "name" : name
     },
     {
         "id" : id,
         "name" : name
     }
]
whereid和nameequal to$(this).attr('id')和$(this).text()where$(this)指的是单个li项目。