jQuery has a lot of useful functions tucked away that can be used to do perform some interesting tasks in Web applications. One of my favorites is the data() function which can be used to cache data and associate it with DOM elements. It’s extremely useful when you want to store data returned from an Ajax call on an element (such as a <tr>) so that you can easily access it later as the user interacts with the page.
Here’s a segment from the jQuery Tips and Tricks course that Elijah Manor and myself created for Pluralsight that demonstrates how the data() function can be used in applications. In the video I show how to cache data retrieved from an Ajax call, discuss when it’s appropriate to do this and when it’s not, and cover some other miscellaneous topics along the way.
Working with the jQuery data() Function