|
osdir.com mailing list archive F.A.Q. -since 2001! |
|
|
|
Subject: [jQuery] Generating a unique id - msg#02004List: lang.javascript.jquery
by Date: Prev Next Date Index by Thread: Prev Next Thread Index
Hi,
Sometimes, I find it necessary to generate an id for an element, so I created the following little plugin. I'm posting it here in case it may be of use to anyone else, and as a possible candidate for jQuery core. $.generateId = function() { return arguments.callee.prefix + arguments.callee.count++; }; $.generateId.prefix = 'jq$'; $.generateId.count = 0; $.fn.generateId = function() { return this.each(function() { this.id = $.generateId(); }); }; Regards - Mark Gibson
Thread at a glance:
Previous Message by Date:Re: [jQuery] Tabs plugin: Truly bookmarkable finallyJörn Zaefferer schrieb: >> See here in action: >> http://stilbuero.de/jquery/tabs/ > > Yeah! I like it! > > Now the only thing I'm missing is a more complex container where only the > content is animated, I think I mentioned that already. Just take the > Automatic height example and animate only the text, not the container... > > -- Jörn Yes, you are right. Maybe I can achieve that even with the existing markup. I will have a look for that... -- Klaus Next Message by Date:Re: [jQuery] New Selectors plugin: Adds :focus, :modified, :input, :text etcThey're in the svn? Great. I'll take them out of my plugin in that case. J?rn Zaefferer wrote: > >> >> Simple http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ >> selectors >> plugin to add more specific query :selectors to JQuery. > > Actually :input, :text etc. are already in SVN. But :input doesn't select > button elements, I need to add that. > :focus and :modified are great additions, good job. > > -- J?rn > -- > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal f?r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > _______________________________________________ > jQuery mailing list > discuss@xxxxxxxxxx > http://jquery.com/discuss/ > > -- View this message in context: http://www.nabble.com/New-Selectors-plugin%3A-Adds-%3Afocus%2C-%3Amodified%2C-%3Ainput%2C-%3Atext-etc-tf2343998.html#a6527567 Sent from the JQuery mailing list archive at Nabble.com. Previous Message by Thread:[jQuery] jButton --> MovedThe jButton plugin can from now on be found at: http://gilles.jquery.com/jButton/ -- Gilles Next Message by Thread:Re: [jQuery] Generating a unique idI would suggest changing this line: this.id = $.generateId();...to: this.id = this.id || $.generateId();... in order to avoid reassigning an ID to elements which have already received one. On 9/27/06, Mark Gibson <mgibson@xxxxxxxxxxxxxxx> wrote: Hi,Sometimes, I find it necessary to generate an id for an element,so I created the following little plugin.I'm posting it here in case it may be of use to anyone else,and as a possible candidate for jQuery core. $.generateId = function() { return arguments.callee.prefix + arguments.callee.count++;};$.generateId.prefix = 'jq$';$.generateId.count = 0;$.fn.generateId = function() { return this.each(function() { this.id = $.generateId(); });};Regards- Mark Gibson_______________________________________________jQuery mailing list discuss@xxxxxxxxxxhttp://jquery.com/discuss/ _______________________________________________ jQuery mailing list discuss@xxxxxxxxxx http://jquery.com/discuss/
blog comments powered by Disqus
|
|