Result
jQuery
$("ol li").each(function (i) {
//要素の数を取得
i = i+1;
//要素の頭に数値を加える
$(this).prepend('<span class="number"> No.'+i+'</span>');
});
css
.number{
color:red;
display:inline-block;
margin-right:15px;
font-size:20px;
}
ol{margin:25px;}
li{margin-bottom:15px;}
html
<ol>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
</ol>
via
[myphp file=’jquery-other-snippets’]
