普通のリストに任意の文字列と番号を加える

Ads

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

jQuery Sequential List


Warning: include(/home/youhei0828/kachibito.net/public_html/wp-content/themes/cocoon-master/my-php/jquery-other-snippets.php): Failed to open stream: No such file or directory in /home/youhei0828/kachibito.net/public_html/wp-content/themes/kachibito7_with_cocoon_child/functions-module/shortcode/add-post-myphp.php on line 7

Warning: include(): Failed opening '/home/youhei0828/kachibito.net/public_html/wp-content/themes/cocoon-master/my-php/jquery-other-snippets.php' for inclusion (include_path='.:/opt/php-8.1.29/data/pear') in /home/youhei0828/kachibito.net/public_html/wp-content/themes/kachibito7_with_cocoon_child/functions-module/shortcode/add-post-myphp.php on line 7