$('.past').addClass($('.copy')
but if you want to do it with another way
$(document).ready(function(){
$(".copy").click(function(){
var array = ['color','width','height', 'background-color', 'border'];
var $this = $(this);
$.each( array , function(item, value) {
$(".past").css(value, $this.css(value));
});
});
});
another way or you can say the best way
(function($){
$.fn.getStyleObject = function(){
var dom = this.get(0);
var style;
var returns = {};
if(window.getComputedStyle){
var camelize = function(a,b){
return b.toUpperCase();
};
style = window.getComputedStyle(dom, null);
for(var i = 0, l = style.length; i < l; i++){
var prop = style[i];
var camel = prop.replace(/\-([a-z])/g, camelize);
var val = style.getPropertyValue(prop);
returns[camel] = val;
};
return returns;
};
if(style = dom.currentStyle){
for(var prop in style){
returns[prop] = style[prop];
};
return returns;
};
return this.css();
}
})(jQuery);
$.fn.copyCSS = function(source){
var styles = $(source).getStyleObject();
this.css(styles);
}
$('.past').copyCSS('div.copy');
2
solved copy all css property [closed]