How does jQuery .data() work?

Have a look at the source for it.

From a quick glimpse, it looks like it’s storing the data in that cache variable that is created on line 2.

Edit:

Here’s a quick demo that finds the data in the cache: http://jsfiddle.net/CnET9/

You can also dump $.cache to your console and explore it manually.

Leave a Comment