The fastest easiest way to get it right.

uniqueId

NAME

x6.uniqueId

FUNCTION

Generates a random number between 1 and 1,000,000 that is not being used as the ID for any DOM object. Useful for generating unique and content-free Id's for DOM objects.

EXAMPLE

Example usage would be:

     var x = document.createElement('div');
     x.id = x6.uniqueId();

RESULT

id - returns the id

SOURCE

uniqueId: function() {
    var retval = 0;
    while( $('#'+retval).length > 1  || retval==0) {
        var retval=Math.floor(Math.random()*1000000);
    }
    return retval;
},

User Comments

There are no user comments yet on this page.


Add A Comment

Comments will not appear until after they are moderated. Comments are usually moderated within a few hours on weekdays, but may take longer on weekends and holidays.

Name or nickname: (This will appear with your comment)


Email (this will never be displayed)


Enter your comment here. Use [b] and [/b] for bold, [i] and [/i] for italic, and [pre] and [/pre] for code samples. All literal HTML and PHP that you enter will be escaped out and displayed as you enter it.


Home |  Documentation |  Download |  Credits |  Contact |  Login
Andromeda © Copyright 2004-2010, Licensed under the GPL Version 2