Posted By

satie83 on 05/17/12


Tagged

javascript html DOM jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


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  

You need to login to post a comment.