我有一个像这样的列表:
<ul>
<li><span class="date">2011 05 01</span><p>Text...</p></li>
<li><span class="date">2011 05 01</span><p>Text...</p></li>
<li><span class="date">2011 04 01</span><p>Text...</p></li>
<li><span class="date">2011 04 01</span><p>Text...</p></li>
<li><span class="date">2010 03 01</span><p>Text...</p></li>
<li><span class="date">2010 02 01</span><p>Text...</p></li>
</ul>
我需要使用jQuery按年份和月份对项目进行分组,如下所示:
<ul>
<li class="year">2011
<ul>
<li class="month>May
<ul>
<li class="item"><span class="date">2011 05 01</span><p>Text...</p></li>
<li class="item"><span class="date">2011 05 01</span><p>Text...</p></li>
</ul>
</li>
<li class="month>April
<ul>
<li class="item"><span class="date">2011 04 01</span><p>Text...</p></li>
<li class="item"><span class="date">2011 04 01</span><p>Text...</p></li>
</ul>
</li>
</ul>
</li>
<li class="year">2010
<ul>
<li class="month>March
<ul>
<li class="item"><span class="date">2011 03 01</span><p>Text...</p></li>
</ul>
</li>
<li class="month>February
<ul>
<li class="item"><span class="date">2011 02 01</span><p>Text...</p></li>
</ul>
</li>
</ul>
</li>
</ul>
谢谢。