Sujith
Sujith

Reputation: 161

JavaScript statement not working in IE

I have the below CSS line in one of my javascript function and it is working fine in other browsers except IE (Internet Explorer). The height of the element is like 4px when page loaded.

element.setAttribute('style', "height: 15px;") 

Does anyone has the solution for this?

Upvotes: 0

Views: 58

Answers (2)

Amit
Amit

Reputation: 15387

Try this

 element.style.cssText = 'height: 15px';

Upvotes: 0

Quentin
Quentin

Reputation: 944545

Some versions of IE (and newer versions of it when they are in backwards compatible rendering modes) have a horribly broken implementation of setAttribute which just sets the property of the same name instead of setting the attribute.

Don't use it, and set the (correct) equivalent property directly instead.

element.style.height = "15px";

Upvotes: 1

Related Questions