jQuery:为无序列表编号

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery:为无序列表编号相关的知识,希望对你有一定的参考价值。

Here’s a very simple script which adds numbers sequentially to an unordered list using jQuery
  1. <script type="text/javascript"
  2. src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js">
  3. </script>
  4.  
  5. <script type="text/javascript">
  6. $(function () {
  7. $('ul > li').each(function () {
  8. $(this).prepend("(" +
  9. ($(this).index() + 1) + ") ");
  10. });
  11. })
  12. </script>

以上是关于jQuery:为无序列表编号的主要内容,如果未能解决你的问题,请参考以下文章