Number LI's using jQuery

后端 未结 1 1666
小鲜肉
小鲜肉 2021-01-15 20:58

I have an ordered list, but I want to number is manually in a separate span tag than use the default list-style: decimal;



        
1条回答
  •  时光说笑
    2021-01-15 21:48

    $(function() {
      $("ol > li").each(function(i, n) {
        $(this).prepend("" + (i+1) + " ");
      });
    });
    

    You'll need to disable the standard markers too:

    ol { list-style-type: none; }
    

    Adjust as required.

    0 讨论(0)
提交回复
热议问题