Return to Snippet

Revision: 9602
at November 13, 2008 15:15 by 1man


Updated Code
//Store a color
$(this).data('color', $(this).css('color'));
//Retrieve the color later
$(this).css('color', $(this).data('color'));
//Remove the data
$(this).removeData('color');

Revision: 9601
at November 13, 2008 10:45 by 1man


Initial Code
//Store a color
$(this).data('color', $(this).css('color'));
//Retrieve the color later
$(this).css('color', $(this).data('color'));

Initial URL


Initial Description
I didn't realise until now you could do this in jQuery, very useful. Store a value for later use, then remove it.

Initial Title
The jQuery Data Store

Initial Tags
data, jquery

Initial Language
JavaScript