Return to Snippet

Revision: 18121
at September 23, 2009 04:44 by chchrist


Updated Code
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:". "});

Revision: 18120
at September 23, 2009 04:20 by chchrist


Initial Code
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);	
		}
	});
};

Initial URL

                                

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

Initial Title
jQuery auto numbering

Initial Tags
plugin, jquery

Initial Language
jQuery