mikul
mikul

Reputation: 536

Get all computed style of an element

i want to get all the style applyed to an element e.g like in chrome developer tool you have seen at top right section called "Computed Style" i want to get all the list is there any other simple way to get all the list and property

Source Code

i tried this javascript but it is not what i want, i have to manual write css property

i just want all the style applied to a element earlier or by default

Upvotes: 5

Views: 3199

Answers (1)

Emre Erkan
Emre Erkan

Reputation: 8482

Try using this function (updated your 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() function is from I does Javascript!

Upvotes: 2

Related Questions