Element Storage in MooTools

  • Avinash
  • 0
  • Aug 19, 2011
  • Web Development

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.

Related Posts

Written by Avinash

Avinash Zala currently working at a leading web development company as a Sr. PHP Web Developer. He is the founder of the Xpert Developer. He has completed B.E. in Information Technology. Born and brought up in Ahmedabad. He loves to code and coding is all about passion for him. Follow him on twitter at Avinash Zala & Xpert Developer.

View all posts by: