Simple jQuery plugin for generating unique identifiers.
First of all You must include plugin file in Your html document, after that You should have access to $.uniqueId() function.
This function has few configuration options:
attribute
- Default: 'id' - name of attribute to "generate".prefix
- Default: 'uid_' - prefix for generated value.suffix
- Default: '' - suffix for generated value.counter_start
- Default: 1 - start number to search.
Full configured function will look like this:
$.uniqueId({
attribute: 'id',
prefix:'uid_',
suffix:'',
counter_start: 1
});
and for empty document it returns: 'uid_1'
Please see file example.html to better understand mechanism of this plugin but it's really simple. Quick example let's assume that you want to find first available attribute "id" for mask: article_{article number}_show. So You should use plugin like this:
var id=$.uniqueId({prefix:'article_',suffix:'_show'});
Whole code in this repository is Under MIT license