获取元素的所有计算样式

mik*_*kul 5 javascript css jquery

我想将所有样式应用于元素,例如在chrome开发者工具中,您已经在右上角看到了“计算样式”,我想获取所有列表,还有其他任何简单的方法来获取所有列表和属性

源代码

我试过这个javascript,但这不是我想要的,我必须手动写css属性

我只想更早或默认将所有样式应用于元素

Emr*_*kan 2

尝试使用这个功能(更新你的 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];
}
Run Code Online (Sandbox Code Playgroud)

getComputedStyle()函数来自我做Javascript!