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

Christian Heilmann codepo8 at gmail.com
Tue Sep 20 15:29:45 CDT 2005


> Hi guys,
> 
> Perplexing, but while Mozilla and Firefox both faithfully perform the following, IE seems to take offense:
> 
>         if (currentImage.className == 'smallPic')
>         {
>                 imageDivision.className = 'smallPic';
>                 currentImage.removeAttribute('class');
>         }
> 
> To cut a long story short, currentImage is later appended to imageDivision which is, in turn, appended to the main document.  Viewing the generated source from IE reveals that both the new division and the nested image both have the class attribute.  Can anyone suggest why this might be happening?  Is it a known bug or a 'feature'?

A bug, use className='' to remove. If you are likely to have more than
one class, remove any whitespace with the class name as MSIE/Mac
chokes on classes followed by a space at the end of the class value or
a space in front of the first class.

-- 
Chris Heilmann 
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/  
Binaries: http://www.onlinetools.org/


More information about the thelist mailing list