获取元素的所有计算样式
我希望得到所有应用于元素的样式,例如你在右上角看到的Chrome开发者工具中称为“Computed Style”我希望获得所有列表是否有任何其他简单的方法来获取所有列表和属性
源代码
我试过这个javascript但它不是我想要的,我必须手动编写css属性
我只是希望早期或默认情况下应用于元素的所有样式
尝试使用此function( 更新你的jsFiddle );
function getComputedStyle(elm, style) { var computedStyle; if (typeof elm.currentStyle != "undefined") { computedStyle = elm.currentStyle; } else { computedStyle = document.defaultView.getComputedStyle(elm, null); } return computedStyle[style]; }
getComputedStyle()
函数来自我做的Javascript!