如何使用jQuery获取元素的所有计算出的样式? [英] how to get all the calculated styles of an element with jQuery?
问题描述
我想复制一个元素的所有已计算的css并将其应用于另一个元素.通过计算样式,我的意思是,例如,如果元素的宽度为100%,但其父元素的宽度为200px,则元素的计算宽度将为200px.如何访问元素的所有这些样式?
I want to copy all the calculated css of an element and apply it to another element. By calculated style, I mean for examply if the element's width is 100%, but it's parent's width is 200px, the elements calculated width would be 200px. how can I access all of these styles for an element ?
推荐答案
在使用Majid的答案进行了进一步研究之后,我发现Jquery的".css"方法也返回了计算样式,并且更好,因为它解决了浏览器差异 http://api.jquery.com/css/
after further research using Majid's answer, I found out that Jquery's ".css" method return computed style as well, and is better because it accounts for browser difference http://api.jquery.com/css/
这篇关于如何使用jQuery获取元素的所有计算出的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!