Skip to content

Simple jQuery plugin for generating unique identifiers.

License

Notifications You must be signed in to change notification settings

DevStrefa/jquery.uniqueId

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery.uniqueId 1.0.0

Simple jQuery plugin for generating unique identifiers.

Usage

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'});

License

Whole code in this repository is Under MIT license

About

Simple jQuery plugin for generating unique identifiers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published