迟了两年,但我有您想要的解决方案。这是我写的一个插件(通过将另一个人的函数包装为插件格式),可以完全满足您的要求,但可以在所有浏览器(甚至是IE)中获得所有可能的样式。
jquery.getStyleObject.js:
(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;i<style.length;i++){ var prop = style[i]; var camel = prop.replace(/-([a-z])/g, camelize); var val = style.getPropertyValue(prop); returns[camel] = val; } return returns; } if(dom.currentStyle){ style = dom.currentStyle; for(var prop in style){ returns[prop] = style[prop]; } return returns; } return this.css(); }})(jQuery);基本用法非常简单:
var style = $("#original").getStyleObject(); // copy all computed CSS properties$("#original").clone() // clone the object .parent() // select it's parent .appendTo() // append the cloned object to the parent, after the original // (though this could really be anywhere and ought to be somewhere // else to show that the styles aren't just inherited again .css(style); // apply cloned styles希望能有所帮助。



