Skip to content Skip to sidebar Skip to footer

Can't Get Display Attribute

I am trying to get display attribute about an element using style.display. But its not returning anything. Have a look at the JsFiddle one. http://jsfiddle.net/4v5LS/1/ There is no

Solution 1:

You can use getComputedStyle()

document.getElementById('button').onclick = function() {
     element = document.getElementById('box');
     style = window.getComputedStyle(element),
     display = style.getPropertyValue('display');
    alert(display);
}

fiddle

Post a Comment for "Can't Get Display Attribute"