比方說,我有編碼像這樣的列表:如何將li分組爲ul然後進入父李?
<ul id="Folder" name="Folder">
<li value="0">Top Folder</li>
<li value="11">2nd Folder 01</li>
<li value="17" class="third">---3rd Folder 01-01</li>
<li value="18" class="third">---3rd Folder 01-02</li>
<li value="383" class="fouth">------4th Folder 01-02-01</li>
<li value="384" class="fifth">---------5th Folder 01-02-01-01</li>
<li value="385" class="fifth">---------5th Folder 01-02-01-02</li>
<li value="386" class="fifth">---------5th Folder 01-02-01-03</li>
<li value="387" class="fifth">---------5th Folder 01-02-01-04</li>
<li value="388" class="fifth">---------5th Folder 01-02-01-05</li>
<li value="19" class="third">---3rd Folder 03</li>
<li value="20" class="third">---3rd Folder 04</li>
<li value="22" class="third">---3rd Folder 05</li>
<li value="130" class="fouth">------5th Folder 01-02-05-01</li>
<li value="131" class="fouth">------5th Folder 01-02-05-02</li>
<li value="132" class="fouth">------5th Folder 01-02-05-03</li>
<li value="133" class="fouth">------5th Folder 01-02-05-04</li>
<li value="134" class="fouth">------5th Folder 01-02-05-05</li>
<li value="398" class="fouth">------5th Folder 01-02-05-06</li>
<li value="158">2nd Folder 02</li>
<li value="257" class="third">---3rd Folder 02-01</li>
<li value="258" class="third">---3rd Folder 02-02</li>
<li value="259" class="third">---3rd Folder 02-03</li>
<li value="16">2nd Folder 03</li>
<li value="382" class="third">---3rd Folder 03-01</li>
<li value="51" class="third">---3rd Folder 03-02</li>
<li value="113" class="fouth">------4th Folder 03-02-01</li>
<li value="125" class="fouth">------4th Folder 03-02-02</li>
</ul>
而且我用的jQuery:
$('li.fifth').wrapAll('<ul>');
$('li.fouth').wrapAll('<ul>');
$('li.third').wrapAll('<ul>');
這樣我就可以組所有的第5,第4和第3裏成了一團。
現在我遇到的問題是,我如何將第5個ul組移動到第4個li父節點?並將第4個ul組變成第3個li等...
你不能像這樣嵌套'ul'元素。你在哪裏得到這個HTML? – Blender 2013-02-28 01:59:11
以下是來自Blenders的準確評論,您想要實現什麼 - 您是否希望製作嵌套列表以顯示某種類型或層次結構? – 2013-02-28 02:01:20
大家好, 我想要做的是將許多李嵌入不同的ul。 這是原來的問題:http://stackoverflow.com/questions/15124387/jquery-group-li-into-ul-based-on-dash 我得到了一個下拉,我想讓他們成爲多個巢名單。 – Simpledog 2013-02-28 02:19:03