/ 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.
Expand |
Embed | Plain Text
//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');
Comments
Subscribe to comments
You need to login to post a comment.

Oh that's awesome, i didn't know that ingenious ability. Thanks alot =)
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.