Например
так:
var $test = $('.test');
$test.css({
color: 'red',
background: 'white'
});
console.log(oldCSS($test, ['color', 'background']));
function oldCSS($element, prop) {
var current = $element.attr('style');
var old = $element.removeAttr('style').css(prop);
$element.attr('style', current);
return old;
}
Или в виде
jQuery метода, например $(selector).stylesheet(props)
jQuery.fn.stylesheet = function(props) {
var current = this.attr('style');
var old = this.removeAttr('style').css(props);
this.attr('style', current);
return old;
};
var $test = $('.test');
$test.css({
color: 'red'
});
var color = $test.stylesheet('color');
console.log(color);