for i = 1 to ...
uniqueId = uniquePrefix + i;
On Dec 26, 6:21 pm, McLars <[EMAIL PROTECTED]> wrote:
> I believe that is what $.data(element) does, it returns a unique id.
> However, it only returns an integer number. I would prefer to combine
> it with a few characters as well, but I suppose that
modify from this js
uniquePrefix = "_" + (new Date() - 0) // ms string
for i = 1 to whatever
On Dec 26, 6:21 pm, McLars <[EMAIL PROTECTED]> wrote:
> I believe that is what $.data(element) does, it returns a unique id.
> However, it only returns an integer number. I would prefer to combine
> it
I believe that is what $.data(element) does, it returns a unique id.
However, it only returns an integer number. I would prefer to combine
it with a few characters as well, but I suppose that isn't strictly
necessary.
Byron's function above is a good example of how you could use it. But
if you do
Why not just keep a "global" variable, like:
var _id = 0;
and when you create the new item, use that counter to make like "New_"
+ _id, and then increment the counter
you could use $.data() to get a unique id, something like:
$.extend($.fn, {
id : function () {
return this.each(function () {
$(this).attr("id", "jQuery_" + $.data(this));
});
}
});
example usage :
$('').id().appendTo('body');
result :
hope this helps :)
Bah...
Test if there's something in a document.getElementById( your_id ). If
there is, choose another id, if not, go on.
No?
On Dec 24, 12:18 am, Guy Fraser <[EMAIL PROTECTED]> wrote:
> > On Dec 23, 5:09 am, dn2965 <[EMAIL PROTECTED]> wrote:
>
> >> hello everyone
> >> i want to know a way to g
Just generate a random number with Javascript, and throw in a few
characters for good measure. Like maybe the tagName followed by a four
or five (you could go higher if you'er paranoid) digit random number.
And/or you could use a time stamp of some sort.
If you want to go the extra mile, you coul
A quick Google search should give you a JS function that can return a
GUID type string that can be used as an ID. Here's a snippet I modified
for a custom object I needed once:
//create a GUID type identifier.
//NOTE: note truely unique, but duplicates are unlikely.
// based on code found at :
> On Dec 23, 5:09 am, dn2965 <[EMAIL PROTECTED]> wrote:
>
>> hello everyone
>> i want to know a way to general unique id for new append element. like
>> EXT's .id();
>>
I don't think there is any equivalent in jQuery at present. It would be
useful though as I've had several occasions m
I'm not sure to understand your question but... If you want to
generate the id attribute, you can use
.attr('id', your_unique_id )
Is that what you were looking for? :)
On Dec 23, 5:09 am, dn2965 <[EMAIL PROTECTED]> wrote:
> hello everyone
> i want to know a way to general unique id for new ap
> i want to know a way to general unique id for new append element. like
> EXT's .id();
You could use this little plugin--untested:
jQuery.fn.uniqueId = function(suffix, clobber) {
if ( suffix == null )
suffix = "UniqueId";
return this.each(function(){
if ( !this.id || clobber )
11 matches
Mail list logo