我有以下无序列表:
<ul class="primary">
<li id="1"><span>Product Family A</span>
<ul class="secondary">
<li><span>A.1</span></li>
<li><span>A.2</span></li>
</ul>
</li>
<li id="2"><span>Product Family B</span>
<ul class="secondary">
<li><span>B.1</span></li>
</ul>
</li>
etc...
</ul>
我想用 jQuery 生成下面的输出。有人可以帮忙吗?
product_family:[{
id:1,
products:[{
model: A1,
model: A2
}],
product_family:[{
id:2,
products:[{
model: B1
}]
谢谢!