Element Storage in MooTools

MooTools 1.2 has introduces the really interesting and useful feature which is element storage. With this feature we can store any type of variable on elements object without creating a new variable.

This is just like you store the information in variable and get it when you needs. But instead of variable you will store your information on HTML element without creating a new variable. isn’t this interesting?

store() function is used to store the any type of value in element and retrieve() function is used to retrieve the stored value.

You can store anything on an element like arrays, objects, numbers, strings, other elements, doesn’t matter.

Note: retrieve() function will return TRUE if value found and return FALSE if value not found.

Basic Usage of the element storage in Mootools:

// Store value in element $('id_of_element').store('key','value'); // Retrieve Value from Element $('id_of_element').retrieve('key');
// Store value in element
$('id_of_element').store('key','value');

// Retrieve Value from Element
$('id_of_element').retrieve('key');

Here are some of my MooTools work where I have used the mootools element storage.

Share This Article