我在WordPress的职位列表中的这个样子的:jQuery的分组按首字母
<div class="products uk-grid uk-grid-width-medium-1-4">
<a href="#custom-url"><h3>AShape(14)</h3></a>
<a href="#custom-url"><h3>AShape(20)</h3></a>
<a href="#custom-url"><h3>CShape(38)</h3></a>
<a href="#custom-url"><h3>FShape(1)</h3></a>
<a href="#custom-url"><h3>FShape(4)</h3></a>
<a href="#custom-url"><h3>ZShape(2)</h3></a>
<a href="#custom-url"><h3>ZShape(24)</h3></a>
</div>
我需要找到一些方法来通过脚本的所有链接,并在信集团改造它。因此,应采取的首字母从链接所有<h3>
,使组像这样:
<div class="products uk-grid uk-grid-width-medium-1-4">
<div>
<span>A</span>
<a href="#custom-url"><h3>AShape(14)</h3></a>
<a href="#custom-url"><h3>AShape(20)</h3></a>
</div>
<div>
<span>C</span>
<a href="#custom-url"><h3>CShape(38)</h3></a>
</div>
<div>
<span>F</span>
<a href="#custom-url"><h3>FShape(1)</h3></a>
<a href="#custom-url"><h3>FShape(4)</h3></a>
</div>
<div>
<span>Z</span>
<a href="#custom-url"><h3>ZShape(2)</h3></a>
<a href="#custom-url"><h3>ZShape(24)</h3></a>
</div>
</div>
如何,我可以使用jQuery做呢? 这里我有简单的codepen:http://codepen.io/ponciusz/pen/EPgQKP
随机附带说明,我建议将锚元素放在'h3'元素中.. –