我想生成以下对象:
var ideaBoard = {
"Staff Retreat" : {
"Games" : [
{"title" : "Rockband", "details" : "1hr"},
{"title" : "Texas Hold em", "details" : "30min"}
],
"Talks" : [
{"title" : "The Old You", "details" : "Dr. Smith"}
]
}
}
来自以下 HTML:
<div id="data">
<ul><span class="board-title">Staff Retreat</span>
<li><span class="category-title">Games</span>
<ul>
<li>
<span class="title">Rockband</span>
<span class="details">1hr</span>
</li>
<li>
<span class="title">Texas Hold em</span>
<span class="details">30min</span>
</li>
</ul>
</li>
<li><span class="category-title">Talks</span>
<ul>
<li>
<span class="title">The Old You</span>
<span class="details">Dr. Smith</span>
</li>
</ul>
</li>
</ul>
</div>
我是循环/数组/对象的新手 - 所以我非常感谢您的帮助!
如果有帮助,我在这个项目的其他地方使用 jQuery。
谢谢!