Posted By

chchrist on 09/23/09


Tagged

plugin jquery autonumbering


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

chchrist


jQuery auto numbering


 / Published in: jQuery
 

This plugin created in order to prepend() numbering to each matched element

  1. jQuery.fn.autoNumbering = function(options) {
  2. var defaults = {
  3. inverted: false,
  4. delimiter: ". "
  5. }
  6.  
  7. var itemsLength = this.length;
  8. var opts = jQuery.extend(defaults,options);
  9.  
  10. return this.each(function(index) {
  11. if(opts.inverted) {
  12. jQuery(this).prepend(itemsLength+opts.delimiter);
  13. itemsLength--;
  14. } else {
  15. jQuery(this).prepend((index+1)+opts.delimiter);
  16. }
  17. });
  18. };
  19.  
  20. /***TO USE***/
  21.  
  22. $('your element').autoNumbering({inverted:true,delimiter:". "});

Report this snippet  

You need to login to post a comment.