I have a problem to seperate a ul list in 5 parts. The list is something like:
<ul class="designer-list">
<li>7 title</li>
<li>alpha</li>
<li>charlie</li>
<li>charles</li>
<li>lima</li>
</ul>
with this jQuery I put the first character on top
$(document).ready(function(){
var lastCharacter = '';
var list = $('ul.designer-list li');
list.each(function() {
var $this = $(this);
var firstCharacter = $this.text().trim().charAt(0);
if(firstCharacter != lastCharacter) {
$this.before('<li class="first-character"><span>'+firstCharacter+'</span></li>');
lastCharacter = firstCharacter;
}
});
});
that makes this: 7 7 title A alpha C Charlie Charles L Lima
That works fine, but I want to separate the list in 5 columns. If I try something like:
$this.before('</ul></li><li class="first-character"><span>'+firstCharacter+'</span><ul>');
The Browser closes the tag. Does anybody have an idea?
I want the following output:
7 E K S W
List List List List List
A F L T X
List List List List List