Posted By

1man on 11/13/08


data jquery store

Versions (?)

Who likes this?

7 people have marked this snippet as a favorite


The jQuery Data Store

 / Published in: JavaScript

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

  1. //Store a color
  2. $(this).data('color', $(this).css('color'));
  3. //Retrieve the color later
  4. $(this).css('color', $(this).data('color'));
  5. //Remove the data
  6. $(this).removeData('color');

Report this snippet  


RSS Icon Subscribe to comments
Posted By: VaiT on November 13, 2008

Oh that's awesome, i didn't know that ingenious ability. Thanks alot =)

Posted By: RambleCampbell on March 26, 2009

Does anyone know exactly how this mechanism works? I assumed it was adding custom attributes to the element, but I don't see that in Firefox, which typically shows that kind of thing. Is it simply stored in browser memory? I'm curious about exactly how it works, so I know the limitations. Thanks.

Posted By: Jacky888 on September 30, 2018

prestigio psp3531duo dw53b01g frpbypassnow

Posted By: on November 7, 2018

the 8 best ul rated power strip bestpowerstrips

You need to login to post a comment.