/ Published in: jQuery
This plugin created in order to prepend() numbering to each matched element
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
jQuery.fn.autoNumbering = function(options) { var defaults = { inverted: false, delimiter: ". " } var itemsLength = this.length; var opts = jQuery.extend(defaults,options); return this.each(function(index) { if(opts.inverted) { jQuery(this).prepend(itemsLength+opts.delimiter); itemsLength--; } else { jQuery(this).prepend((index+1)+opts.delimiter); } }); }; /***TO USE***/ $('your element').autoNumbering({inverted:true,delimiter:". "});