Journal of a Web Professional in Brussels

25 excellent jquery tips

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.

The Conversation

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Belgians do IT better _