Using the example data that started the post... // create a DIV with text, and append to #cardholder... var businessCard = jQuery('<div class="bcard">Business Card</ div>').appendTo('#cardholder').get(0); // store data against the DIV element created above... jQuery.data( businessCard //element , 'businessCards' //arbitrary (non-conflicting) name , { 'name' : 'some name' , 'address' : 'some address' , 'phoneno' : 'some phoneno' , 'email' : 'some email' } );
To retrieve the data (for the element stored in businessCard) at any time... var bci = jQuery.data(businessCard, 'businessCards'); // add another card (not storing the element in a variable this time)... jQuery.data( jQuery('<div class="bcard">Business Card 2</ div>').appendTo('#cardholder').get(0) , 'businessCards' //same name! , { 'name' : 'some other name' , 'address' : 'some other address' , 'phoneno' : 'some other phoneno' , 'email' : 'some other email' } ); To retrieve all card info below #cardholder... var bcards = []; jQuery('#cardholder .bcard').each(function() { bcards.push(jQuery.data(this, 'businessCards')); }); (or variations thereof) On Nov 4, 9:35 pm, "Oliver Boermans" <[EMAIL PROTECTED]> wrote: > Thanks Mike, > can the metadata plugin be used to store variables determined on load > for later use? > So when the variables are subsequently required the code to retrieve > them is simple and quick. > > Cheers > Ollie > > On 05/11/2007, Mike Alsup <[EMAIL PROTECTED]> wrote: > > > > > > Is there a relatively simple plugin that takes advantage of jQuerys > > > "expando management" that anyone can recommend as an example? > > > > The most promising information I have discovered is in the release > > > notes of jQuery 1.2 where John mentions jQuery.data() : <http:// > > > docs.jquery.com/Release:jQuery_1.2/Internals#Expando_Management> > > >http://jqueryjs.googlecode.com/svn/trunk/plugins/metadata/jquery.meta...