i'm trying to make a selective form field reset to initial values
this is achieved by copying all initial values into a new attribute
$('.billing input:text').each(function () { $(this).attr('original_value', $(this).attr('value')); });
and then restoring it as necessary with
$(this).attr('value', $(this).attr('original_value'));
this consistently fails in FF2/Win for form fields which had an empty string as their initial value and works for other fields
so to reproduce:
have two fields, one with value="foo", other with value=""
set both field contents to "bar", manually
run mentioned code
expected behaviour:
field1 reverts to "foo", field2 reverts to ""
found behaviour:
field1 reverts to "foo", field2 stays as "bar"
firebug shows both fields as reverted, but firefox does not update the displayed value for field2
workaround:
instead of .attr('value', ) use .removeAttr('value')
using .val() instead of .attr('value') makes no difference