New here? Start with the essentials and go from there.

Tuesday, January 29, 2008

IE Fun Fact: "style" attribute is in "cssText"

Thanks to Dave Sussman for the tip-off that IE keeps the string value of the style attribute in the non-standard style.cssText property.

Workaround
Though in Firefox you can write:
var style = el.getAttributeNode('style').value;

IE requires that you instead say:
var style = el.style.cssText;

This means that any iterations through the Node.attributes NamedNodeMap must be special-cased when the name is "style".

0 comments:

Post a Comment

Blog Widget by LinkWithin