Posted By

satie83 on 05/17/12

Viewed 6 times

jQuery: Numbering an Unordered List


/ Published in: jQuery

URL: http://www.devcurry.com/2011/06/jquery-numbering-unordered-list.html

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>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.