Jon Hobbs-Smith wrote an excellent roundup of 25 good coding habits when using jquery.

If your javascript library of choice is jquery, make sure you read it, it’s worth a 40USD book!

I was particularly interested to read tip#14:

14. Even better, use jQuery’s internal data() method to store state

It’s not very well documented for some reason but jQuery has an internal data() method which can be used to store information in key/value pairs against any DOM element. Storing a piece of data is as simple as this…

$('#myDiv').data('currentState', 'off');

Argl, i wish i had known that earlier… Still, amazing little feature.