我正在寻找在这种情况下包装列表项目。
<ul class="subNav" style="top: 160px;">
<li class="level2 nav-3-1-1 first 3">3</li>
<li class="level2 nav-3-1-2 W">W</li>
<li class="level2 nav-3-1-2 W">W</li>
<li class="level2 nav-3-1-3 V">V</li>
<li class="level2 nav-3-1-4 T">T</li>
<li class="level2 nav-3-1-5 T">T</li>
<li class="level2 nav-3-1-6 T">T</li>
<li class="level2 nav-3-1-2 W">W</li>
<li class="level2 nav-3-1-7 S">S</li>
<li class="level2 nav-3-1-8 S">S</li>
<li class="level2 nav-3-1-9 S">S</li>
<li class="level2 nav-3-1-10 S">S</li>
<li class="level2 nav-3-1-11 R">R</li>
<li class="level2 nav-3-1-20 L">L</li>
<li class="level2 nav-3-1-42 A">A</li>
<li class="level2 nav-3-1-43 A">A</li>
<li class="level2 nav-3-1-44 Y">Y</li>
</ul>
此HTML是cms的产品。
我需要使用jQuery将所有li包含在相同的字母字母类中。
这就是我想要的:
<ul class="subNav" style="top: 160px;">
<li>
<ul>
<li class="level2 nav-3-1-2 W"></li>
<li class="level2 nav-3-1-3 W"></li>
<li class="level2 nav-3-1-4 W"></li>
</ul>
</li>
<li>
<ul>
<li class="level2 nav-3-1-5 T"></li>
<li class="level2 nav-3-1-6 T"></li>
</ul>
</li>
<li>
<ul>
<li class="level2 nav-3-1-7 S"></li>
<li class="level2 nav-3-1-8 S"></li>
<li class="level2 nav-3-1-9 S"></li>
</ul>
</li>
<li>
<ul>
<li class="level2 nav-3-1-11 R"></li>
<li class="level2 nav-3-1-20 R"></li>
<li class="level2 nav-3-1-42 R"></li>
</ul>
</li>
<li>
<ul>
<li class="level2 nav-3-1-43 A"></li>
<li class="level2 nav-3-1-44 A"></li>
</ul>
</li>
</ul>
我该怎么做?