[thelist] removeAttribute('class') not working in IE

Iain iain at firelightning.com
Tue Sep 20 16:40:18 CDT 2005


Thank you, Christian and Andy both.  I think I understand the mechanics of the problem now, so I'd better get on with my rewriting.  :)

Iain

Andrew Clover wrote:
> This is a consequence of IE's hopeless hacked-together implementation of 
> DOM Level 1 Core. IE in its wisdom translates getAttribute, setAttribute 
> and removeAttribute into access to normal object.member access. This means:
> 
>   a. you can do stupid things like getAttribute('parentNode'), and
>      are disallowed from setting custom attributes that happen to have
>      the same name as a non-attribute member (especially annoying as
>      it may break your scripts when IE grows new member functions)
> 
>   b. it doesn't work when you use attributes that have a different
>      name as a property, like class/className and for/htmlFor. You
>      can do:
> 
>      currentImage.removeAttribute('class');
>      currentImage.removeAttribute('className');
> 
>      to makes sure that both IE and compliant browsers see the change,
>      but it's probably easier just to use the member access
>      (currentImage.className) instead as this works consistently.
> 



More information about the thelist mailing list