.data Method: Storing Class Attribute Values and Restoring Them

.data Method: Storing Class Attribute Values and Restoring Them

Total newbie to jQuery.

I have a set of <span> elements, each of which has the @class attribute with multiple values. I have several functions that allow users to change the CSS of the <span> content in various ways. I want to provide a "Restore" button that sets every <span> element back to the @class settings it had when the page loaded.

Here's the code I've got to this point:

1. Iterate over each <span> and store the @class value in the element's .data collection:

 $( document.body ).click(function() {
   $('span').each(function(i) {
      $(this).data('original_classes', $(this).attr('class'))
   });
});

2. Have a Restore All function:

function restore_all()
    {     
       $('span').data('original_classes');
    }

3. Have a button to call restore_all():

 <input type="button" onClick="restore_all(this);" value="Restore All" />

Not sure where I've gone wrong. I'm not getting any errors but also am not seeing the original @class values restored.

Thanks