$('.spanner').each(function (index) { var characters = $(this).text().split(""); $this = $(this); $this.empty(); $.each(characters, function (i, el) { $this.append('' + el + ''); }); $('.spanner span').each(function(i) { $(this).css({ 'left' : 40 + (i * 40) + 'px', 'z-index' : (i + 1) }); }); });